hmr 0.4.2__py3-none-any.whl → 0.4.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hmr
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Hot Module Reload for Python
5
5
  Project-URL: repository, https://github.com/promplate/pyth-on-line/tree/reactivity
6
6
  Requires-Python: >=3.12
@@ -1,14 +1,14 @@
1
- hmr-0.4.2.dist-info/METADATA,sha256=0dGqIVXUA-EX7VuNsQSOLtOvX5aKy-noYyrRLZpSwkc,258
2
- hmr-0.4.2.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- hmr-0.4.2.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
1
+ hmr-0.4.3.dist-info/METADATA,sha256=gJvXslME9Vjx3o-BtCThGvA0a77QQ9ozUehjgosaY0I,258
2
+ hmr-0.4.3.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ hmr-0.4.3.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=U06vshcVhZ0sb218gcmHtEhfgTNAGtQ7zyvPz2w5qKM,1292
6
- reactivity/helpers.py,sha256=1KCpre2HTFZrngEKkI2HwSFMkCmsUCq2aPEbp0y3kKg,5140
6
+ reactivity/helpers.py,sha256=DVwhsEEs9aRcsyMqTdF5eRG-Z0zVhS7AbmR-Y-PXCkg,5321
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=Esb1fYiBW0SLxQ0MPXby25ZgIIZhIp-M3b2KiqpffmU,2094
10
- reactivity/hmr/core.py,sha256=x71UilKjeH-HH72ta_u46tnRV3Fb28KXqoqtGdGabko,12250
10
+ reactivity/hmr/core.py,sha256=97pqCf5wt0YOb5vAi4I1z9qagKXMEy_xQvL6LW9DHmI,11498
11
11
  reactivity/hmr/hooks.py,sha256=jIFpe4CNxfaS9RcR4OIodx_sOZlnJ_IA1T1RtHPXhwU,945
12
12
  reactivity/hmr/utils.py,sha256=-PO-LMP4sc3IP-Bn_baq2w9IFWBZ3zGesgRn5wR6bS0,1555
13
- reactivity/primitives.py,sha256=mB6cbHKDqtilOfgaEhshtRWJq9s0nPEKqRK0hfCoyFE,5671
14
- hmr-0.4.2.dist-info/RECORD,,
13
+ reactivity/primitives.py,sha256=sPuIRi3pnAV7wV42rqD0j07HNkz4Bk4VxJWhdYToeZE,5907
14
+ hmr-0.4.3.dist-info/RECORD,,
reactivity/helpers.py CHANGED
@@ -112,11 +112,13 @@ class Reactive[K, V](Subscribable, MutableMapping[K, V]):
112
112
 
113
113
  def __iter__(self):
114
114
  self.track()
115
- return iter(self._signals)
115
+ unset = self.UNSET
116
+ return (key for key, signal in self._signals.items() if signal.get(track=False) is not unset)
116
117
 
117
118
  def __len__(self):
118
119
  self.track()
119
- return len(self._signals)
120
+ unset = self.UNSET
121
+ return sum(signal.get(track=False) is not unset for signal in self._signals.values())
120
122
 
121
123
  def __repr__(self):
122
124
  self.track()
reactivity/hmr/core.py CHANGED
@@ -15,7 +15,7 @@ from weakref import WeakValueDictionary
15
15
  from .. import Reactive, batch
16
16
  from ..functional import create_effect
17
17
  from ..helpers import DerivedMethod
18
- from ..primitives import BaseComputation, BaseDerived, Derived, Signal
18
+ from ..primitives import BaseDerived, Derived, Signal
19
19
  from .hooks import call_post_reload_hooks, call_pre_reload_hooks
20
20
 
21
21
 
@@ -103,17 +103,6 @@ class ReactiveModule(ModuleType):
103
103
  # unsubscribe it because we want invalidation to be fine-grained
104
104
  dep.subscribers.remove(load)
105
105
  load.dependencies.remove(dep)
106
- elif isinstance(dep, BaseComputation):
107
- visited = set() # cache visited nodes, maybe share cache between iteration too (?)
108
- to_visit: set[BaseComputation] = {dep}
109
- while to_visit and (current := to_visit.pop()) not in visited:
110
- visited.add(current)
111
- if load in current.dependencies:
112
- # unsubscribe it to avoid circular dependencies
113
- dep.subscribers.remove(load)
114
- load.dependencies.remove(dep)
115
- break
116
- to_visit.update(i for i in current.dependencies if isinstance(i, BaseComputation))
117
106
 
118
107
  @property
119
108
  def load(self):
@@ -349,4 +338,4 @@ def cli():
349
338
  SyncReloader(entry).keep_watching_until_interrupt()
350
339
 
351
340
 
352
- __version__ = "0.4.2"
341
+ __version__ = "0.4.3"
reactivity/primitives.py CHANGED
@@ -212,4 +212,13 @@ class Derived[T](BaseDerived[T]):
212
212
 
213
213
 
214
214
  def _pulled(sub: Subscribable):
215
- return any(not isinstance(s, BaseDerived) or _pulled(s) for s in sub.subscribers)
215
+ visited = set()
216
+ to_visit: set[Subscribable] = {sub}
217
+ while to_visit:
218
+ visited.add(current := to_visit.pop())
219
+ for s in current.subscribers:
220
+ if not isinstance(s, BaseDerived):
221
+ return True
222
+ if s not in visited:
223
+ to_visit.add(s)
224
+ return False
File without changes