55````` @customdoc
66juliacall.Main - Constant
77
8- The Julia `Main` module, as a [`ModuleValue `](#juliacall.ModuleValue ).
8+ The Julia `Main` module, as a [`Jl `](#juliacall.Jl ).
99
1010In interactive scripts, you can use this as the main entry-point to JuliaCall:
1111```python
@@ -20,18 +20,6 @@ The modules `Base`, `Core` and `PythonCall` are also available.
2020
2121## Utilities
2222
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-
3523````` @customdoc
3624juliacall.newmodule - Function
3725
@@ -45,74 +33,70 @@ A new module with the given name.
4533## [ Wrapper types] (@id julia-wrappers)
4634
4735Apart 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 `
7553
7654````` @customdoc
77- juliacall.AnyValue - Class
55+ juliacall.Jl - Class
7856
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.
8158
8259Supports `repr(x)`, `str(x)`, attributes (`x.attr`), calling (`x(a,b)`), iteration,
8360comparisons, `len(x)`, `a in x`, `dir(x)`.
8461
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.
8864
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).
9368
9469###### 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).
9877`````
9978
10079````` @customdoc
101- juliacall.NumberValue - Class
80+ juliacall.JlCollection - Class
81+
82+ Wraps any Julia collection. It is a subclass of `collections.abc.Collection`.
10283
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!`.
10587
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.
10993`````
11094
11195````` @customdoc
112- juliacall.ArrayValue - Class
96+ juliacall.JlArray - Class
11397
11498This wraps any Julia `AbstractArray` value. It is a subclass of
115- `collections.abc.Collection `.
99+ `juliacall.JlCollection `.
116100
117101It supports zero-up indexing, and can be indexed with integers or slices. Slicing returns a
118102view of the original array.
@@ -130,22 +114,20 @@ copy of the original array.
130114###### Members
131115- `ndim`: The number of dimensions.
132116- `shape`: Tuple of lengths in each dimension.
133- - `copy()`: A copy of the array.
134117- `reshape(shape)`: A reshaped view of the array.
135118- `to_numpy(dtype=None, copy=True, order="K")`: Convert to a numpy array.
136119`````
137120
138121````` @customdoc
139- juliacall.VectorValue - Class
122+ juliacall.JlVector - Class
140123
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
142125`collections.abc.MutableSequence` and behaves similar to a Python `list`.
143126
144127###### Members
145128- `resize(size)`: Change the length of the vector.
146129- `sort(reverse=False, key=None)`: Sort the vector in-place.
147130- `reverse()`: Reverse the vector.
148- - `clear()`: Empty the vector.
149131- `insert(index, value)`: Insert the value at the given index.
150132- `append(value)`: Append the value to the end of the vector.
151133- `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
156138`````
157139
158140````` @customdoc
159- juliacall.DictValue - Class
141+ juliacall.JlDict - Class
160142This wraps any Julia `AbstractDict` value. It is a subclass of `collections.abc.Mapping` and
161143behaves similar to a Python `dict`.
162144`````
163145
164146````` @customdoc
165- juliacall.SetValue - Class
147+ juliacall.JlSet - Class
166148This wraps any Julia `AbstractSet` value. It is a subclass of `collections.abc.Set` and
167149behaves similar to a Python `set`.
168150`````
169151
170152````` @customdoc
171- juliacall.IOValue - Class
153+ juliacall.JlIOBase - Class
172154
173155This wraps any Julia `IO` value. It is a subclass of `io.IOBase` and behaves like Python
174156files.
175157
176- There are also subtypes `BinaryIOValue ` and `TextIOValue `, which are subclasses of
158+ There are also subtypes `JlBinaryIO ` and `JlTextIO `, which are subclasses of
177159`io.BufferedIOBase` (buffered bytes) and `io.TextIOBase` (text).
178160`````
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