@@ -2,39 +2,47 @@ const pyjlcollectiontype = pynew()
2
2
3
3
pyjlcollection_clear (x) = (empty! (x); Py (nothing ))
4
4
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 )
6
7
7
8
pyjlcollection_eq (self, other) = pybool ((self == pyjlvalue (other)):: Bool )
8
9
9
10
function init_collection ()
10
11
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
+ )
38
46
pycopy! (pyjlcollectiontype, jl. JlCollection)
39
47
end
40
48
@@ -51,7 +59,6 @@ pyjlcollection(x) = pyjl(pyjlcollectiontype, x)
51
59
pyjlcollection (x:: AbstractSet ) = pyjlset (x)
52
60
pyjlcollection (x:: AbstractArray ) = pyjlarray (x)
53
61
pyjlcollection (x:: AbstractDict ) = pyjldict (x)
54
- export pyjlcollection
55
62
56
63
Py (x:: Base.ValueIterator ) = pyjlcollection (x)
57
64
Py (x:: Base.RefValue ) = pyjlcollection (x)
0 commit comments