hmr 0.5.2__py3-none-any.whl → 0.5.2.2__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.
- hmr-0.5.2.2.dist-info/METADATA +36 -0
- {hmr-0.5.2.dist-info → hmr-0.5.2.2.dist-info}/RECORD +6 -6
- reactivity/hmr/core.py +2 -2
- reactivity/primitives.py +18 -2
- hmr-0.5.2.dist-info/METADATA +0 -8
- {hmr-0.5.2.dist-info → hmr-0.5.2.2.dist-info}/WHEEL +0 -0
- {hmr-0.5.2.dist-info → hmr-0.5.2.2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: hmr
|
3
|
+
Version: 0.5.2.2
|
4
|
+
Summary: Hot Module Reload for Python
|
5
|
+
Project-URL: repository, https://github.com/promplate/pyth-on-line/tree/reactivity
|
6
|
+
Requires-Python: >=3.12
|
7
|
+
Requires-Dist: watchfiles<2,>=0.21; sys_platform != "emscripten"
|
8
|
+
Description-Content-Type: text/markdown
|
9
|
+
|
10
|
+
<div align="center">
|
11
|
+
|
12
|
+
# HMR for Python
|
13
|
+
|
14
|
+
<sup> on-demand · fine-grained · push-pull reactivity </sup>
|
15
|
+
|
16
|
+
[](https://pypi.org/project/hmr/)
|
17
|
+
[](https://github.com/promplate/pyth-on-line/blob/reactivity/packages/hmr/pyproject.toml)
|
18
|
+
[](https://pepy.tech/projects/hmr)
|
19
|
+
|
20
|
+
</div>
|
21
|
+
|
22
|
+
HMR means Hot Module Reload / [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/). It is a feature that allows part of your app to be updated at runtime without a full rerun.
|
23
|
+
|
24
|
+
- The module whose source file **you changed** will rerun
|
25
|
+
- The module / function that **depend on** the changed module will rerun
|
26
|
+
- Other modules that are unaffected (like third-party libraries) will not rerun
|
27
|
+
|
28
|
+
Thus, in contrast to the traditional way of **cold-reloading** Python applications (like [watchfiles CLI](https://watchfiles.helpmanual.io/cli/)), HMR is just more efficient.
|
29
|
+
|
30
|
+
Unlike static-analysis tools like [Tach](https://github.com/gauge-sh/tach), HMR works by tracking the dependencies between names and modules **during runtime** through a [reactive system](https://wikipedia.org/wiki/Reactive_programming).
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
If you are running your entry file with `python foo.py bar baz ...`, you can just replace it with `hmr foo.py bar baz ...`.
|
35
|
+
|
36
|
+
You can also try it with `uvx` or `pipx`. If you are using a virtual environment, it is recommended to install `hmr` in the virtual environment instead of globally.
|
@@ -1,14 +1,14 @@
|
|
1
|
-
hmr-0.5.2.dist-info/METADATA,sha256=
|
2
|
-
hmr-0.5.2.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
3
|
-
hmr-0.5.2.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
|
1
|
+
hmr-0.5.2.2.dist-info/METADATA,sha256=oweBlpOxlLru70fMiG1JKAx6aS-B1-e8Xx4qATH2EwI,2001
|
2
|
+
hmr-0.5.2.2.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
3
|
+
hmr-0.5.2.2.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
|
4
4
|
reactivity/__init__.py,sha256=pX-RUzkezCC1x4eOWGxNhXbwrbvBLP_3pQuZr9eZz1Y,300
|
5
5
|
reactivity/functional.py,sha256=jJLEq88w5ag2cXuD1T118uEjnEg37_mqvWmFkb47KVY,1300
|
6
6
|
reactivity/helpers.py,sha256=rcrCXy1mmlei-if_BN4nSgS2IG9kBj-jq1YRwEfcITo,5329
|
7
7
|
reactivity/hmr/__init__.py,sha256=S5ZIHqCRpevdzWuhS0aCua_S8F0LkK0YNg6IgeTScFQ,177
|
8
8
|
reactivity/hmr/__main__.py,sha256=uIcyjR5gMFIXH_3hS0B3SD00RirVf7GIct-uItx675o,64
|
9
9
|
reactivity/hmr/api.py,sha256=sKDQV7uKRVoDifTZKrLQGZP-fzgYbdVjfEOC6ki4NKY,2280
|
10
|
-
reactivity/hmr/core.py,sha256=
|
10
|
+
reactivity/hmr/core.py,sha256=U6aq96IP1Ox1B486F_HdI9qYUF6q2bC5rsH6xpdafhw,11693
|
11
11
|
reactivity/hmr/hooks.py,sha256=jIFpe4CNxfaS9RcR4OIodx_sOZlnJ_IA1T1RtHPXhwU,945
|
12
12
|
reactivity/hmr/utils.py,sha256=h9m7iRXlvsLTrHoXV9gEVbhz3XsPK4KgnStYoCAWE5I,1616
|
13
|
-
reactivity/primitives.py,sha256=
|
14
|
-
hmr-0.5.2.dist-info/RECORD,,
|
13
|
+
reactivity/primitives.py,sha256=Cq1tBNmVFCjnCq30TCku-l1JimlC5fJh9Z2GHcfWNUY,6483
|
14
|
+
hmr-0.5.2.2.dist-info/RECORD,,
|
reactivity/hmr/core.py
CHANGED
@@ -79,7 +79,7 @@ class ReactiveModule(ModuleType):
|
|
79
79
|
self.__namespace_proxy = NamespaceProxy(namespace, self)
|
80
80
|
self.__file = file
|
81
81
|
|
82
|
-
|
82
|
+
__class__.instances[file.resolve()] = self
|
83
83
|
|
84
84
|
@property
|
85
85
|
def file(self):
|
@@ -341,4 +341,4 @@ def cli():
|
|
341
341
|
reloader.keep_watching_until_interrupt()
|
342
342
|
|
343
343
|
|
344
|
-
__version__ = "0.5.2"
|
344
|
+
__version__ = "0.5.2.2"
|
reactivity/primitives.py
CHANGED
@@ -3,6 +3,22 @@ from typing import Any, Self, overload
|
|
3
3
|
from weakref import WeakKeyDictionary, WeakSet
|
4
4
|
|
5
5
|
|
6
|
+
def _equal(a, b):
|
7
|
+
if a is b:
|
8
|
+
return True
|
9
|
+
comparison_result = a == b
|
10
|
+
for _ in range(3): # pandas DataFrame's .all() returns a Series, which is still incompatible :(
|
11
|
+
try:
|
12
|
+
if comparison_result:
|
13
|
+
return True
|
14
|
+
except ValueError as e:
|
15
|
+
if ".all()" in str(e) and hasattr(comparison_result, "all"): # array-like instances
|
16
|
+
comparison_result = comparison_result.all()
|
17
|
+
else:
|
18
|
+
return False
|
19
|
+
return False
|
20
|
+
|
21
|
+
|
6
22
|
class Subscribable:
|
7
23
|
def __init__(self):
|
8
24
|
super().__init__()
|
@@ -69,7 +85,7 @@ class Signal[T](Subscribable):
|
|
69
85
|
return self._value
|
70
86
|
|
71
87
|
def set(self, value: T):
|
72
|
-
if not self._check_equality or self._value
|
88
|
+
if not self._check_equality or not _equal(self._value, value):
|
73
89
|
self._value = value
|
74
90
|
self.notify()
|
75
91
|
return True
|
@@ -186,7 +202,7 @@ class Derived[T](BaseDerived[T]):
|
|
186
202
|
value = self.fn()
|
187
203
|
self.dirty = False
|
188
204
|
if self._check_equality:
|
189
|
-
if value
|
205
|
+
if _equal(value, self._value):
|
190
206
|
return
|
191
207
|
elif self._value is self.UNSET: # do not notify on first set
|
192
208
|
self._value = value
|
hmr-0.5.2.dist-info/METADATA
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: hmr
|
3
|
-
Version: 0.5.2
|
4
|
-
Summary: Hot Module Reload for Python
|
5
|
-
Project-URL: repository, https://github.com/promplate/pyth-on-line/tree/reactivity
|
6
|
-
Requires-Python: >=3.12
|
7
|
-
Requires-Dist: watchfiles<2,>=0.21; sys_platform != "emscripten"
|
8
|
-
|
File without changes
|
File without changes
|