5
5
````` @customdoc
6
6
juliacall.Main - Constant
7
7
8
- The Julia `Main` module, as a [`ModuleValue `](#juliacall.ModuleValue ).
8
+ The Julia `Main` module, as a [`Jl `](#juliacall.Jl ).
9
9
10
10
In interactive scripts, you can use this as the main entry-point to JuliaCall:
11
11
```python
@@ -20,18 +20,6 @@ The modules `Base`, `Core` and `PythonCall` are also available.
20
20
21
21
## Utilities
22
22
23
- ````` @customdoc
24
- juliacall.convert - Function
25
-
26
- ```python
27
- convert(T, x)
28
- ```
29
-
30
- Convert `x` to a Julia object of type `T`.
31
-
32
- You can use this to pass an argument to a Julia function of a specific type.
33
- `````
34
-
35
23
````` @customdoc
36
24
juliacall.newmodule - Function
37
25
@@ -45,74 +33,70 @@ A new module with the given name.
45
33
## [ Wrapper types] (@id julia-wrappers)
46
34
47
35
Apart from a few fundamental immutable types, all Julia values are by default converted into
48
- Python to some [ ` AnyValue ` ] ( #juliacall.AnyValue ) object, which wraps the original value, but
49
- giving it a Pythonic interface.
50
-
51
- Subclasses of [ ` AnyValue ` ] ( #juliacall.AnyValue ) provide additional Python semantics. For
52
- example a Julia vector is converted to a [ ` VectorValue ` ] ( #juliacall.VectorValue ) which
53
- satisfies the Python sequence interface and behaves very similar to a list.
54
-
55
- There is also a [ ` RawValue ` ] ( #juliacall.RawValue ) object, which gives a stricter
56
- "Julia-only" interface, documented below. These types all inherit from ` ValueBase ` :
57
-
58
- - ` ValueBase `
59
- - [ ` RawValue ` ] ( #juliacall.RawValue )
60
- - [ ` AnyValue ` ] ( #juliacall.AnyValue )
61
- - [ ` NumberValue ` ] ( #juliacall.NumberValue )
62
- - ` ComplexValue `
63
- - ` RealValue `
64
- - ` RationalValue `
65
- - ` IntegerValue `
66
- - [ ` ArrayValue ` ] ( #juliacall.ArrayValue )
67
- - [ ` VectorValue ` ] ( #juliacall.VectorValue )
68
- - [ ` DictValue ` ] ( #juliacall.DictValue )
69
- - [ ` SetValue ` ] ( #juliacall.SetValue )
70
- - [ ` IOValue ` ] ( #juliacall.IOValue )
71
- - ` BinaryIOValue `
72
- - ` TextIOValue `
73
- - [ ` ModuleValue ` ] ( #juliacall.ModuleValue )
74
- - [ ` TypeValue ` ] ( #juliacall.TypeValue )
36
+ Python to a [ ` Jl ` ] ( #juliacall.Jl ) object, which wraps the original value and gives it a
37
+ Pythonic interface.
38
+
39
+ Other wrapper classes provide more specific Python semantics. For example a Julia vector can
40
+ be converted to a [ ` JlVector ` ] ( #juliacall.JlVector ) which satisfies the Python sequence
41
+ interface and behaves very similar to a list.
42
+
43
+ - ` JlBase `
44
+ - [ ` Jl ` ] ( #juliacall.Jl )
45
+ - [ ` JlCollection ` ] ( #juliacall.JlCollection )
46
+ - [ ` JlArray ` ] ( #juliacall.JlArray )
47
+ - [ ` JlVector ` ] ( #juliacall.JlVector )
48
+ - [ ` JlDict ` ] ( #juliacall.JlDict )
49
+ - [ ` JlSet ` ] ( #juliacall.JlSet )
50
+ - [ ` JlIOBase ` ] ( #juliacall.JlIOBase )
51
+ - ` JlBinaryIO `
52
+ - ` JlTextIO `
75
53
76
54
````` @customdoc
77
- juliacall.AnyValue - Class
55
+ juliacall.Jl - Class
78
56
79
- Wraps any Julia object, giving it some basic Python semantics. Subtypes provide extra
80
- semantics.
57
+ Wraps any Julia object, giving it some basic Python semantics.
81
58
82
59
Supports `repr(x)`, `str(x)`, attributes (`x.attr`), calling (`x(a,b)`), iteration,
83
60
comparisons, `len(x)`, `a in x`, `dir(x)`.
84
61
85
- Calling, indexing, attribute access, etc. will convert the result to a Python object
86
- according to [this table](@ref jl2py). This is typically a builtin Python type (for
87
- immutables) or a subtype of `AnyValue`.
62
+ Calling, indexing, attribute access, etc. will always return a `Jl`. To get the result
63
+ as an ordinary Python object, you can use the `.jl_to_py()` method.
88
64
89
- Attribute access can be used to access Julia properties as well as normal class members. In
90
- the case of a name clash, the class member will take precedence. For convenience with Julia
91
- naming conventions, `_b` at the end of an attribute is replaced with `!` and `_bb` is
92
- replaced with `!!`.
65
+ Attribute access (`x.attr`) can be used to access Julia properties except those starting
66
+ and ending with `__` (since these are Python special methods) or starting with `jl_` or
67
+ `_jl_` (which are reserved by `juliacall` for Julia-specific methods).
93
68
94
69
###### Members
95
- - `_jl_raw()`: Convert to a [`RawValue`](#juliacall.RawValue). (See also [`pyjlraw`](@ref).)
96
- - `_jl_display()`: Display the object using Julia's display mechanism.
97
- - `_jl_help()`: Display help for the object.
70
+ - `jl_callback(*args, **kwargs)`: Calls the Julia object with the given arguments.
71
+ Unlike ordinary calling syntax, the arguments are passed as `Py` objects instead of
72
+ being converted.
73
+ - `jl_display()`: Display the object using Julia's display mechanism.
74
+ - `jl_eval(expr)`: If the object is a Julia `Module`, evaluates the given expression.
75
+ - `jl_help()`: Display help for the object.
76
+ - `jl_to_py()`: Convert to a Python object using the [usual conversion rules](@ref jl2py).
98
77
`````
99
78
100
79
````` @customdoc
101
- juliacall.NumberValue - Class
80
+ juliacall.JlCollection - Class
81
+
82
+ Wraps any Julia collection. It is a subclass of `collections.abc.Collection`.
102
83
103
- This wraps any Julia `Number` value. It is a subclass of `numbers.Number` and behaves
104
- similar to other Python numbers.
84
+ Julia collections are arrays, sets, dicts, tuples, named tuples, refs, and in general
85
+ anything which is a collection of values in the sense that it supports functions like
86
+ `iterate`, `in`, `length`, `hash`, `==`, `isempty`, `copy`, `empty!`.
105
87
106
- There are also subtypes `ComplexValue`, `RealValue`, `RationalValue`, `IntegerValue` which
107
- wrap values of the corresponding Julia types, and are subclasses of the corresponding
108
- `numbers` ABC.
88
+ It supports `in`, `iter`, `len`, `hash`, `bool`, `==`.
89
+
90
+ ###### Members
91
+ - `clear()`: Empty the collection in-place.
92
+ - `copy()`: A copy of the collection.
109
93
`````
110
94
111
95
````` @customdoc
112
- juliacall.ArrayValue - Class
96
+ juliacall.JlArray - Class
113
97
114
98
This wraps any Julia `AbstractArray` value. It is a subclass of
115
- `collections.abc.Collection `.
99
+ `juliacall.JlCollection `.
116
100
117
101
It supports zero-up indexing, and can be indexed with integers or slices. Slicing returns a
118
102
view of the original array.
@@ -130,22 +114,20 @@ copy of the original array.
130
114
###### Members
131
115
- `ndim`: The number of dimensions.
132
116
- `shape`: Tuple of lengths in each dimension.
133
- - `copy()`: A copy of the array.
134
117
- `reshape(shape)`: A reshaped view of the array.
135
118
- `to_numpy(dtype=None, copy=True, order="K")`: Convert to a numpy array.
136
119
`````
137
120
138
121
````` @customdoc
139
- juliacall.VectorValue - Class
122
+ juliacall.JlVector - Class
140
123
141
- This wraps any Julia `AbstractVector` value. It is a subclass of `juliacall.ArrayValue ` and
124
+ This wraps any Julia `AbstractVector` value. It is a subclass of `juliacall.JlArray ` and
142
125
`collections.abc.MutableSequence` and behaves similar to a Python `list`.
143
126
144
127
###### Members
145
128
- `resize(size)`: Change the length of the vector.
146
129
- `sort(reverse=False, key=None)`: Sort the vector in-place.
147
130
- `reverse()`: Reverse the vector.
148
- - `clear()`: Empty the vector.
149
131
- `insert(index, value)`: Insert the value at the given index.
150
132
- `append(value)`: Append the value to the end of the vector.
151
133
- `extend(values)`: Append the values to the end of the vector.
@@ -156,65 +138,23 @@ This wraps any Julia `AbstractVector` value. It is a subclass of `juliacall.Arra
156
138
`````
157
139
158
140
````` @customdoc
159
- juliacall.DictValue - Class
141
+ juliacall.JlDict - Class
160
142
This wraps any Julia `AbstractDict` value. It is a subclass of `collections.abc.Mapping` and
161
143
behaves similar to a Python `dict`.
162
144
`````
163
145
164
146
````` @customdoc
165
- juliacall.SetValue - Class
147
+ juliacall.JlSet - Class
166
148
This wraps any Julia `AbstractSet` value. It is a subclass of `collections.abc.Set` and
167
149
behaves similar to a Python `set`.
168
150
`````
169
151
170
152
````` @customdoc
171
- juliacall.IOValue - Class
153
+ juliacall.JlIOBase - Class
172
154
173
155
This wraps any Julia `IO` value. It is a subclass of `io.IOBase` and behaves like Python
174
156
files.
175
157
176
- There are also subtypes `BinaryIOValue ` and `TextIOValue `, which are subclasses of
158
+ There are also subtypes `JlBinaryIO ` and `JlTextIO `, which are subclasses of
177
159
`io.BufferedIOBase` (buffered bytes) and `io.TextIOBase` (text).
178
160
`````
179
-
180
- ````` @customdoc
181
- juliacall.ModuleValue - Class
182
- This wraps any Julia `Module` value.
183
-
184
- It is the same as [`AnyValue`](#juliacall.AnyValue) except for one additional convenience
185
- method:
186
- - `seval([module=self], code)`: Evaluates the given code (a string) in the given module.
187
- `````
188
-
189
- ````` @customdoc
190
- juliacall.TypeValue - Class
191
-
192
- This wraps any Julia `Type` value.
193
-
194
- It is the same as [`AnyValue`](#juliacall.AnyValue) except that indexing is used to access
195
- Julia's "curly" syntax for specifying parametric types:
196
-
197
- ```python
198
- from juliacall import Main as jl
199
- # equivalent to Vector{Int}() in Julia
200
- jl.Vector[jl.Int]()
201
- ```
202
- `````
203
-
204
- ````` @customdoc
205
- juliacall.RawValue - Class
206
-
207
- Wraps any Julia value with a rigid interface suitable for generic programming.
208
-
209
- Supports `repr(x)`, `str(x)`, attributes (`x.attr`), calling (`x(a,b)`), `len(x)`, `dir(x)`.
210
-
211
- This is very similar to [`AnyValue`](#juliacall.AnyValue) except that indexing, calling,
212
- etc. will always return a `RawValue`.
213
-
214
- Indexing with a tuple corresponds to indexing in Julia with multiple values. To index with a
215
- single tuple, it will need to be wrapped in another tuple.
216
-
217
- ###### Members
218
- - `_jl_any()`: Convert to a [`AnyValue`](#juliacall.AnyValue) (or subclass). (See also
219
- [`pyjl`](@ref).)
220
- `````
0 commit comments