zhmiscellany 6.3.2__py3-none-any.whl → 6.3.5__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
@@ -162,7 +162,7 @@ def save_object_to_file(object, file_name, compressed=False):
162
162
  import lzma
163
163
  with open(file_name, 'wb') as f:
164
164
  if compressed:
165
- f.write(lzma.compress(fast_dill_dumps(object)))
165
+ f.write(lzma.compress(fast_dill_dumps(object), preset=9 | lzma.PRESET_EXTREME))
166
166
  else:
167
167
  f.write(fast_dill_dumps(object))
168
168
 
@@ -180,7 +180,7 @@ def pickle_and_encode(obj):
180
180
  """Pickles an object and URL-safe encodes it."""
181
181
  import base64
182
182
  import lzma
183
- pickled_data = lzma.compress(fast_dill_dumps(obj), 9) # Serialize the object
183
+ pickled_data = lzma.compress(fast_dill_dumps(obj), preset=9 | lzma.PRESET_EXTREME) # Serialize the object
184
184
  encoded_data = base64.urlsafe_b64encode(pickled_data).decode() # Base64 encode
185
185
  return encoded_data
186
186
 
@@ -218,7 +218,7 @@ def chdir_to_script_dir():
218
218
  os.chdir(os.path.dirname(get_script_path()))
219
219
 
220
220
 
221
- def cache(function, *args, compressed=False, **kwargs):
221
+ def cache(function, *args, _cache_compressed=False, **kwargs):
222
222
  """
223
223
  Caches the result of a function call to disk.
224
224
  """
@@ -300,7 +300,7 @@ def cache(function, *args, compressed=False, **kwargs):
300
300
  'function': function,
301
301
  'args': args,
302
302
  'kwargs': kwargs,
303
- 'compressed': compressed
303
+ 'compressed': _cache_compressed
304
304
  }
305
305
 
306
306
  seed_hash = get_hash_orjson(seed)
@@ -308,11 +308,11 @@ def cache(function, *args, compressed=False, **kwargs):
308
308
  cache_file = f'{cache_folder}/cache_{function.__name__}_{seed_hash}.pkl'
309
309
 
310
310
  if os.path.exists(cache_file):
311
- return load_object_from_file(cache_file, compressed=compressed)
311
+ return load_object_from_file(cache_file, compressed=_cache_compressed)
312
312
  else:
313
313
  result = function(*args, **kwargs)
314
314
  zhmiscellany.fileio.create_folder(cache_folder)
315
- save_object_to_file(result, cache_file, compressed=compressed)
315
+ save_object_to_file(result, cache_file, compressed=_cache_compressed)
316
316
  return result
317
317
 
318
318
 
@@ -80,8 +80,8 @@ def raw_multiprocess(func, args=(), fileless=True):
80
80
  cwd = '''+repr(os.getcwd())+'''
81
81
  host_pid = {os.getpid()}
82
82
  os.chdir(os.path.dirname(cwd))
83
- func = dill.loads(lzma.decompress('''+repr(lzma.compress(dill.dumps(func), 9))+'''))
84
- args_list = dill.loads(lzma.decompress('''+repr(lzma.compress(dill.dumps(args), 9))+f'''))
83
+ func = dill.loads(lzma.decompress('''+repr(lzma.compress(dill.dumps(func), preset=9 | lzma.PRESET_EXTREME))+'''))
84
+ args_list = dill.loads(lzma.decompress('''+repr(lzma.compress(dill.dumps(args), preset=9 | lzma.PRESET_EXTREME))+f'''))
85
85
  if __name__ == "__main__":
86
86
  data = [None, None]
87
87
  def sync_host_alive_state():
@@ -110,7 +110,7 @@ if __name__ == "__main__":
110
110
  except:
111
111
  pickled = pickle.dumps([1, None], protocol=5)
112
112
  del data
113
- compressed = lzma.compress(pickled, 9);del pickled
113
+ compressed = lzma.compress(pickled, preset=9 | lzma.PRESET_EXTREME);del pickled
114
114
  sys.stdout.buffer.write({repr(cap_string)} + compressed + {repr(cap_string)})
115
115
  sys.stdout.buffer.flush()
116
116
  '''
@@ -210,13 +210,13 @@ if __name__=="__main__":
210
210
  pickled = dill.dumps(data, protocol=5)
211
211
  except:
212
212
  pickled = pickle.dumps([1, None], protocol=5)
213
- compressed = lzma.compress(pickled, 9)
213
+ compressed = lzma.compress(pickled, preset=9 | lzma.PRESET_EXTREME)
214
214
  encoded = base64.b64encode(compressed).decode('utf-8')
215
215
  print({repr(block_header_str)} + {repr(cap_str)} + encoded + {repr(cap_str)} + '\\n', flush=True, end='')
216
216
  computed = False
217
217
  try:
218
- cls = dill.loads(lzma.decompress({repr(lzma.compress(dill.dumps(input_class), 9))}))
219
- args_list = dill.loads(lzma.decompress({repr(lzma.compress(dill.dumps(args), 9))}))
218
+ cls = dill.loads(lzma.decompress({repr(lzma.compress(dill.dumps(input_class), preset=9 | lzma.PRESET_EXTREME))}))
219
+ args_list = dill.loads(lzma.decompress({repr(lzma.compress(dill.dumps(args), preset=9 | lzma.PRESET_EXTREME))}))
220
220
  computed = True
221
221
  except:
222
222
  data[0] = traceback.format_exc()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zhmiscellany
3
- Version: 6.3.2
3
+ Version: 6.3.5
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=vC1ukkvmh9gv2dXO3XEhMYLzKodQqRKahP83TH0JAHc,22090
11
+ zhmiscellany/fileio.py,sha256=9OjWRMqbpLSaCh83axrLjWIIv8RsDOIKeL4rKnRyKqY,22179
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=NYH5j4B_neuijFYXhbhS_PidvJUKqvwnzHulBGJKZ2o,11350
21
+ zhmiscellany/processing.py,sha256=ZhNAJ5OfCUHuaXj0z6XZ94ZGSK86-EdCyqW-9ILayLg,11524
22
22
  zhmiscellany/rust.py,sha256=cHkSpdtq7QQW3yzBEAYL9lZxLW0h4wal2tsxIOnyTrA,494
23
23
  zhmiscellany/string.py,sha256=A4ilBWSYlrJ0AJ0axvepSSjYCYwYk5X-vRrHNphi_ow,4809
24
- zhmiscellany-6.3.2.dist-info/METADATA,sha256=uErV3G6hiDVI9CCNLh3TK6y-Fgt2DLb-jZdNo0b5IZY,43872
25
- zhmiscellany-6.3.2.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
26
- zhmiscellany-6.3.2.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
27
- zhmiscellany-6.3.2.dist-info/RECORD,,
24
+ zhmiscellany-6.3.5.dist-info/METADATA,sha256=9qnaczarUJXs-eWVHwNvrSlPpDpgAXkcT-18L2bUUuY,43872
25
+ zhmiscellany-6.3.5.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
26
+ zhmiscellany-6.3.5.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
27
+ zhmiscellany-6.3.5.dist-info/RECORD,,