MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / __new__

Method __new__

tests/test_code/py/pytz/lazy.py:139–167  ·  view source on GitHub ↗
(cls, fill_iter=None)

Source from the content-addressed store, hash-verified

137 'union', 'update')
138
139 def __new__(cls, fill_iter=None):
140
141 if fill_iter is None:
142 return set()
143
144 class LazySet(set):
145 pass
146
147 fill_iter = [fill_iter]
148
149 def lazy(name):
150 def _lazy(self, *args, **kw):
151 _fill_lock.acquire()
152 try:
153 if len(fill_iter) > 0:
154 for i in fill_iter.pop():
155 set.add(self, i)
156 for method_name in cls._props:
157 delattr(LazySet, method_name)
158 finally:
159 _fill_lock.release()
160 return getattr(set, name)(self, *args, **kw)
161 return _lazy
162
163 for name in cls._props:
164 setattr(LazySet, name, lazy(name))
165
166 new_set = LazySet()
167 return new_set
168
169# Not all versions of Python declare the same magic methods.
170# Filter out properties that don't exist in this version of Python

Callers

nothing calls this directly

Calls 2

setFunction · 0.85
LazySetClass · 0.70

Tested by

no test coverage detected