zhmiscellany 6.2.7__py3-none-any.whl → 6.2.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
zhmiscellany/fileio.py CHANGED
@@ -238,7 +238,37 @@ def cache(function, *args, **kwargs):
238
238
  return inspect.getsource(obj)
239
239
  except (OSError, TypeError):
240
240
  return str(obj) # Fallback for lambdas/partials
241
-
241
+
242
+ # PANDAS DATAFRAMES: Convert to stable dictionary format
243
+ if hasattr(obj, '__class__') and obj.__class__.__name__ == 'DataFrame':
244
+ try:
245
+ import pandas as pd
246
+ if isinstance(obj, pd.DataFrame):
247
+ # Convert to dict with records orientation for stability
248
+ # Include dtypes to ensure type information is preserved
249
+ return {
250
+ 'data': obj.to_dict(orient='split'),
251
+ 'dtypes': {col: str(dtype) for col, dtype in obj.dtypes.items()},
252
+ 'index_name': obj.index.name,
253
+ 'columns': list(obj.columns)
254
+ }
255
+ except ImportError:
256
+ pass
257
+
258
+ # PANDAS SERIES: Similar handling
259
+ if hasattr(obj, '__class__') and obj.__class__.__name__ == 'Series':
260
+ try:
261
+ import pandas as pd
262
+ if isinstance(obj, pd.Series):
263
+ return {
264
+ 'data': obj.to_dict(),
265
+ 'dtype': str(obj.dtype),
266
+ 'name': obj.name,
267
+ 'index': list(obj.index)
268
+ }
269
+ except ImportError:
270
+ pass
271
+
242
272
  # SETS: Must be sorted to ensure determinism!
243
273
  # JSON doesn't support sets, so we turn them into sorted lists.
244
274
  if isinstance(obj, set):
@@ -255,9 +285,10 @@ def cache(function, *args, **kwargs):
255
285
  # CUSTOM OBJECTS: Try to return their __dict__ or string rep
256
286
  if hasattr(obj, '__dict__'):
257
287
  return obj.__dict__
258
-
288
+
259
289
  # Fallback: String representation (risky if str() format changes)
260
290
  return str(obj)
291
+
261
292
  json_bytes = orjson.dumps(
262
293
  data,
263
294
  default=default_converter,
@@ -1,3 +1,4 @@
1
+ from ._processing_supportfuncs import batch_multiprocess, multiprocess, synchronous_class_multiprocess, ThreadWithResult
1
2
  import threading
2
3
 
3
4
  def start_daemon(**kwargs):
@@ -50,7 +51,6 @@ def batch_threading_gen(targets, max_threads=None, show_errors=True):
50
51
  def batch_multiprocess_threaded(targets_and_args, disable_warning=False, killable=False, daemon=False):
51
52
  import kthread
52
53
  import threading
53
- from ._processing_supportfuncs import batch_multiprocess
54
54
  if killable:
55
55
  thread_method = kthread.KThread
56
56
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zhmiscellany
3
- Version: 6.2.7
3
+ Version: 6.2.9
4
4
  Summary: A collection of useful/interesting python libraries made by zh.
5
5
  Home-page: https://discord.gg/ThBBAuueVJ
6
6
  Author: zh
@@ -8,7 +8,7 @@ zhmiscellany/_resource_files_lookup.py,sha256=hsgPW0dngokgqWrAVAv5rUo-eobzJPjvWH
8
8
  zhmiscellany/cpp.py,sha256=XEUEoIKCDCdY5VgwNWE5oXrGjtsmGdz_MnaVwQmi2dk,179
9
9
  zhmiscellany/dict.py,sha256=dNu3G9qiJeLgE7JY3QD31GJU7EfLsYPqxf8AOhBsYag,81
10
10
  zhmiscellany/discord.py,sha256=yKoigWI3tONfYSoMEynGGEWW1VsXSRdkg8vPbIKwBNI,20312
11
- zhmiscellany/fileio.py,sha256=0QZvCXd9fJ3Rart-kk63KMSwIJ3iCoWvUHtdhd-EM0o,20595
11
+ zhmiscellany/fileio.py,sha256=-W1A_sEymfaqxhiEY-y6h_owBlAyVWNm4PSFn7LVoBI,21991
12
12
  zhmiscellany/gui.py,sha256=OVwuZ_kWHJlgKPeYR7fAAyomNmU-OnxOgXZelVNPm1w,10409
13
13
  zhmiscellany/image.py,sha256=6Hz5sfym_o7FHokGUKeXRsjl89VY_ZMSLnvuSam1icI,8265
14
14
  zhmiscellany/list.py,sha256=BnbYG-lpHmi0C4v8jLfaeXqQdc3opmNgkvY6yz4pasg,1475
@@ -18,10 +18,10 @@ zhmiscellany/misc.py,sha256=0vJFa0MRdKXjLLVeFfMx1Q-b-qrKqpdaq6FzWKz6SMY,32489
18
18
  zhmiscellany/netio.py,sha256=rN17uIbsWqDG9ssmouD7VZqOtlgWObaCsvn2Hrq-k6w,2413
19
19
  zhmiscellany/pastebin.py,sha256=jstR_HRP9fUVcQXp4D8zkqvA0GLHNrDrfhqb9Sc-dL0,6479
20
20
  zhmiscellany/pipes.py,sha256=RlHxsW_M_R6UJUIDgYVS_zfqUwO8kXG8j-0YG5qByjo,4637
21
- zhmiscellany/processing.py,sha256=qvowgj-cHZBaQsSQcQ51ywjX2Q5qRZQTMz3o5QIVEM4,11290
21
+ zhmiscellany/processing.py,sha256=S0Rb6ndTC6N23-kz4hLEeRNgAaWjcMAtt8QNDE8x4v4,11350
22
22
  zhmiscellany/rust.py,sha256=cHkSpdtq7QQW3yzBEAYL9lZxLW0h4wal2tsxIOnyTrA,494
23
23
  zhmiscellany/string.py,sha256=A4ilBWSYlrJ0AJ0axvepSSjYCYwYk5X-vRrHNphi_ow,4809
24
- zhmiscellany-6.2.7.dist-info/METADATA,sha256=9eGtrCR_TY10WA6PKiNZ3-5omZpiYHuOehDyF2xVIjk,43872
25
- zhmiscellany-6.2.7.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
26
- zhmiscellany-6.2.7.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
27
- zhmiscellany-6.2.7.dist-info/RECORD,,
24
+ zhmiscellany-6.2.9.dist-info/METADATA,sha256=92jIwQqgCsL9ZfTi7pPeFNrFYPAIYpjb_K6lNJ6ZlEM,43872
25
+ zhmiscellany-6.2.9.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
26
+ zhmiscellany-6.2.9.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
27
+ zhmiscellany-6.2.9.dist-info/RECORD,,