omlish 0.0.0.dev168__py3-none-any.whl → 0.0.0.dev169__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev168'
2
- __revision__ = 'ecfbedaaef82716f605534252d3eabcc71b2f5c6'
1
+ __version__ = '0.0.0.dev169'
2
+ __revision__ = 'ad8bd22d9c1cd7a5a22af3b9d27906ce64fd8451'
3
3
 
4
4
 
5
5
  #
@@ -0,0 +1,32 @@
1
+ # ruff: noqa: UP006 UP007
2
+ import dataclasses as dc
3
+
4
+
5
+ def cache_dataclass_hash(
6
+ *,
7
+ cached_hash_attr: str = '__dataclass_hash__',
8
+ ):
9
+ def inner(cls):
10
+ if not isinstance(cls, type) and dc.is_dataclass(cls):
11
+ raise TypeError(cls)
12
+
13
+ if (
14
+ cls.__hash__ is object.__hash__ or
15
+ '__hash__' not in cls.__dict__
16
+ ):
17
+ raise TypeError(cls)
18
+
19
+ real_hash = cls.__hash__
20
+
21
+ def cached_hash(self) -> int:
22
+ try:
23
+ return object.__getattribute__(self, cached_hash_attr)
24
+ except AttributeError:
25
+ object.__setattr__(self, cached_hash_attr, h := real_hash(self)) # type: ignore[call-arg]
26
+ return h
27
+
28
+ cls.__hash__ = cached_hash # type: ignore[method-assign]
29
+
30
+ return cls
31
+
32
+ return inner
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omlish
3
- Version: 0.0.0.dev168
3
+ Version: 0.0.0.dev169
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  omlish/.manifests.json,sha256=0BnQGD2dcXEma0Jop2ZesvDNzSj3CAJBNq8aTGuBz9A,7276
2
- omlish/__about__.py,sha256=zpJK1N36A2zarYgLGuGMOmoRcQ1YdO2W0GFM7G2k-Sw,3409
2
+ omlish/__about__.py,sha256=Vbn2IOi3EX8LX5PEfmtAHPOYwizDkndZ2-r_FU5omCw,3409
3
3
  omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
4
4
  omlish/c3.py,sha256=ubu7lHwss5V4UznbejAI0qXhXahrU01MysuHOZI9C4U,8116
5
5
  omlish/cached.py,sha256=UI-XTFBwA6YXWJJJeBn-WkwBkfzDjLBBaZf4nIJA9y0,510
@@ -369,6 +369,7 @@ omlish/lite/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
369
369
  omlish/lite/cached.py,sha256=O7ozcoDNFm1Hg2wtpHEqYSp_i_nCLNOP6Ueq_Uk-7mU,1300
370
370
  omlish/lite/check.py,sha256=0PD-GKtaDqDX6jU5KbzbMvH-vl6jH82xgYfplmfTQkg,12941
371
371
  omlish/lite/contextmanagers.py,sha256=m9JO--p7L7mSl4cycXysH-1AO27weDKjP3DZG61cwwM,1683
372
+ omlish/lite/dataclasses.py,sha256=Yaf56l2Lor8bcPCnhRVxvLnJoFqxKf9l358b3WsK8SM,848
372
373
  omlish/lite/inject.py,sha256=EEaioN9ESAveVCMe2s5osjwI97FPRUVoU8P95vGUiYo,23376
373
374
  omlish/lite/json.py,sha256=7-02Ny4fq-6YAu5ynvqoijhuYXWpLmfCI19GUeZnb1c,740
374
375
  omlish/lite/logs.py,sha256=CWFG0NKGhqNeEgryF5atN2gkPYbUdTINEw_s1phbINM,51
@@ -558,9 +559,9 @@ omlish/text/glyphsplit.py,sha256=Ug-dPRO7x-OrNNr8g1y6DotSZ2KH0S-VcOmUobwa4B0,329
558
559
  omlish/text/indent.py,sha256=6Jj6TFY9unaPa4xPzrnZemJ-fHsV53IamP93XGjSUHs,1274
559
560
  omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
560
561
  omlish/text/random.py,sha256=jNWpqiaKjKyTdMXC-pWAsSC10AAP-cmRRPVhm59ZWLk,194
561
- omlish-0.0.0.dev168.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
562
- omlish-0.0.0.dev168.dist-info/METADATA,sha256=CkmiX1w3Ef334-qtNR8QvHcHiUtJrd3uPwzmUJ1hBZE,4264
563
- omlish-0.0.0.dev168.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
564
- omlish-0.0.0.dev168.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
565
- omlish-0.0.0.dev168.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
566
- omlish-0.0.0.dev168.dist-info/RECORD,,
562
+ omlish-0.0.0.dev169.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
563
+ omlish-0.0.0.dev169.dist-info/METADATA,sha256=CsUpWiDs5ax6CJfLmh_ssyLkwhwgoju6FMPzic0v_58,4264
564
+ omlish-0.0.0.dev169.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
565
+ omlish-0.0.0.dev169.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
566
+ omlish-0.0.0.dev169.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
567
+ omlish-0.0.0.dev169.dist-info/RECORD,,