Skip to content

Commit 066e35a

Browse files
committed
Remove hardcoded dunder list from _coconut_lazy_module
The metaclass __getattr__ handles all attribute access on the lazy module class, making explicit dunder forwarding unnecessary for the current use cases (async_generator, tstr, numpy, trollius, backports.functools_lru_cache). https://claude.ai/code/session_01KBLQLYTdfjLPaR2UJhgnkq
1 parent 6cab116 commit 066e35a

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

coconut/compiler/templates/header.py_template

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
def _coconut_import_module(name):
22
{lazy_module_import}
3-
_coconut_lazy_dunders = ("__call__", "__iter__", "__next__", "__len__", "__contains__", "__getitem__", "__setitem__", "__delitem__", "__reversed__", "__missing__", "__repr__", "__str__", "__format__", "__bytes__", "__hash__", "__int__", "__float__", "__complex__", "__index__", "__round__", "__ceil__", "__floor__", "__trunc__", "__neg__", "__pos__", "__abs__", "__invert__", "__add__", "__radd__", "__iadd__", "__sub__", "__rsub__", "__isub__", "__mul__", "__rmul__", "__imul__", "__truediv__", "__rtruediv__", "__itruediv__", "__floordiv__", "__rfloordiv__", "__ifloordiv__", "__mod__", "__rmod__", "__imod__", "__pow__", "__rpow__", "__ipow__", "__matmul__", "__rmatmul__", "__imatmul__", "__lshift__", "__rlshift__", "__ilshift__", "__rshift__", "__rrshift__", "__irshift__", "__and__", "__rand__", "__iand__", "__or__", "__ror__", "__ior__", "__xor__", "__rxor__", "__ixor__", "__lt__", "__le__", "__gt__", "__ge__", "__eq__", "__ne__", "__enter__", "__exit__", "__aiter__", "__anext__", "__aenter__", "__aexit__", "__await__", "__divmod__", "__rdivmod__", "__nonzero__", "__length_hint__")
43
def _coconut_lazy_module(name, on_import=None, attr=None):
54
_coconut_lazy_state = [None, None]
65
def _coconut_lazy_load():
@@ -33,12 +32,6 @@ def _coconut_lazy_module(name, on_import=None, attr=None):
3332
def __bool__(cls):
3433
return True
3534
__nonzero__ = __bool__
36-
def _coconut_make_lazy_dunder(dname):
37-
def _coconut_lazy_dunder(cls, *args, **kwargs):
38-
return _coconut.getattr(_coconut_lazy_load(), dname)(*args, **kwargs)
39-
return _coconut_lazy_dunder
40-
for _coconut_dunder in _coconut_lazy_dunders:
41-
setattr(_coconut_lazy_meta, _coconut_dunder, _coconut_make_lazy_dunder(_coconut_dunder))
4235
return _coconut_lazy_meta("_coconut_lazy_module", (), {{}})
4336
@_coconut_wraps(_coconut_py_super)
4437
def _coconut_super(type=None, object_or_type=None):

0 commit comments

Comments
 (0)