@@ -2,39 +2,47 @@ const pyjlcollectiontype = pynew()
22
33pyjlcollection_clear (x) = (empty! (x); Py (nothing ))
44
5- pyjlcollection_contains (x, v:: Py ) = pybool (in (@pyconvert (eltype (x), v, (return Py (false ))), x):: Bool )
5+ pyjlcollection_contains (x, v:: Py ) =
6+ pybool (in (@pyconvert (eltype (x), v, (return Py (false ))), x):: Bool )
67
78pyjlcollection_eq (self, other) = pybool ((self == pyjlvalue (other)):: Bool )
89
910function init_collection ()
1011 jl = pyjuliacallmodule
11- pybuiltins. exec (pybuiltins. compile ("""
12- $(" \n " ^ (@__LINE__ ()- 1 ))
13- class JlCollection(JlBase2):
14- __slots__ = ()
15- def __len__(self):
16- return self._jl_callmethod($(pyjl_methodnum (pyint ∘ length)) )
17- def __bool__(self):
18- return self._jl_callmethod($(pyjl_methodnum (pybool ∘ ! isempty)) )
19- def __iter__(self):
20- return self._jl_callmethod($(pyjl_methodnum (pyjliter ∘ Iterator)) )
21- def __hash__(self):
22- return self._jl_callmethod($(pyjl_methodnum (pyjlany_hash)) )
23- def __eq__(self, other):
24- if isinstance(self, type(other)) or isinstance(other, type(self)):
25- return self._jl_callmethod($(pyjl_methodnum (pyjlcollection_eq)) , other)
26- else:
27- return NotImplemented
28- def __contains__(self, v):
29- return self._jl_callmethod($(pyjl_methodnum (pyjlcollection_contains)) , v)
30- def copy(self):
31- return self._jl_callmethod($(pyjl_methodnum (pyjlcollection ∘ copy)) )
32- def clear(self):
33- return self._jl_callmethod($(pyjl_methodnum (pyjlcollection_clear)) )
34- import collections.abc
35- collections.abc.Collection.register(JlCollection)
36- del collections
37- """ , @__FILE__ (), " exec" ), jl. __dict__)
12+ pybuiltins. exec (
13+ pybuiltins. compile (
14+ """
15+ $(" \n " ^ (@__LINE__ ()- 1 ))
16+ class JlCollection(JlBase2):
17+ __slots__ = ()
18+ def __len__(self):
19+ return self._jl_callmethod($(pyjl_methodnum (pyint ∘ length)) )
20+ def __bool__(self):
21+ return self._jl_callmethod($(pyjl_methodnum (pybool ∘ ! isempty)) )
22+ def __iter__(self):
23+ return self._jl_callmethod($(pyjl_methodnum (pyjliter ∘ Iterator)) )
24+ def __hash__(self):
25+ return self._jl_callmethod($(pyjl_methodnum (pyjlany_hash)) )
26+ def __eq__(self, other):
27+ if isinstance(self, type(other)) or isinstance(other, type(self)):
28+ return self._jl_callmethod($(pyjl_methodnum (pyjlcollection_eq)) , other)
29+ else:
30+ return NotImplemented
31+ def __contains__(self, v):
32+ return self._jl_callmethod($(pyjl_methodnum (pyjlcollection_contains)) , v)
33+ def copy(self):
34+ return self._jl_callmethod($(pyjl_methodnum (pyjlcollection ∘ copy)) )
35+ def clear(self):
36+ return self._jl_callmethod($(pyjl_methodnum (pyjlcollection_clear)) )
37+ import collections.abc
38+ collections.abc.Collection.register(JlCollection)
39+ del collections
40+ """ ,
41+ @__FILE__ (),
42+ " exec" ,
43+ ),
44+ jl. __dict__,
45+ )
3846 pycopy! (pyjlcollectiontype, jl. JlCollection)
3947end
4048
@@ -51,7 +59,6 @@ pyjlcollection(x) = pyjl(pyjlcollectiontype, x)
5159pyjlcollection (x:: AbstractSet ) = pyjlset (x)
5260pyjlcollection (x:: AbstractArray ) = pyjlarray (x)
5361pyjlcollection (x:: AbstractDict ) = pyjldict (x)
54- export pyjlcollection
5562
5663Py (x:: Base.ValueIterator ) = pyjlcollection (x)
5764Py (x:: Base.RefValue ) = pyjlcollection (x)
0 commit comments