Icxolu
37e2a4d9c9
implement `PyComplexMethods`
2024-01-27 22:26:53 +01:00
David Hewitt
7927a2e211
add bench for tuple `get_borrowed_item`
2024-01-27 21:12:55 +00:00
David Hewitt
1657109ae0
documentation updates for `PyList::new_bound`
2024-01-27 21:12:55 +00:00
Tpt
f83544910f
Adds conversion between SystemTime and datetime
2024-01-27 17:43:51 +01:00
Icxolu
f86053e2c2
implement `PyTracebackMethods`
2024-01-27 11:34:32 +01:00
Mate Kovacs
f32becacc7
fix ugly example
2024-01-20 11:47:27 +09:00
David Hewitt
d1b072222a
Merge pull request #3582 from mkovaxx/pyclass_complex_enum
...
Full ADT support with pyclass for complex enums
2024-01-19 14:17:28 +00:00
Mate Kovacs
3ed5ddb0ec
feat: support pyclass on complex enums
2024-01-18 22:04:42 +09:00
David Hewitt
7366b1a386
Merge pull request #3730 from Tpt/chrono-tz
...
Conversion between chrono_tz::Tz and zoneinfo.ZoneInfo
2024-01-15 14:48:27 +00:00
David Hewitt
4504a7c96e
fix some nightly lints 2024-01-12
2024-01-12 13:34:17 +00:00
Tpt
72f0c73925
Conversion between chrono_tz::Tz and zoneinfo.ZoneInfo
2024-01-08 15:19:49 +01:00
David Hewitt
50e33d86c7
add `call_bound` and `call_method_bound`
2024-01-03 13:24:14 +00:00
David Hewitt
53d25f7ff2
add new `PyTuple` constructors
2023-12-30 21:37:46 +00:00
David Hewitt
a9f867c2cb
begin drafting `Bound<T>` migration guide
2023-12-29 14:42:31 +00:00
David Hewitt
3da1aac2dd
add `gil-refs` feature to aid migration
2023-12-29 14:42:31 +00:00
David Hewitt
46c3190a17
clean up remnants of deprecated & removed features
2023-12-29 13:36:46 +00:00
Adam Reichold
4dc6c1643e
Turn calls of __traverse__ into no-ops for unsendable pyclass if on the wrong thread
...
Adds a "threadsafe" variant of `PyCell::try_borrow` which will fail instead of
panicking if called on the wrong thread and use it in `call_traverse` to turn GC
traversals of unsendable pyclasses into no-ops if on the wrong thread.
This can imply leaking the underlying resource if the originator thread has
already exited so that the GC will never run there again, but it does avoid hard
aborts as we cannot raise an exception from within `call_traverse`.
2023-12-23 15:01:08 +01:00
Adam Reichold
1b3dc6d7ac
Merge pull request #3661 from PyO3/iter-output-type
...
Replace (A)IterNextOutput by autoref-based specialization to allow returning arbitrary value
2023-12-20 12:53:42 +00:00
Adam Reichold
5528895f3e
Relax the error type in the Result<Option<T>, E>> specializations for __(a)next__.
2023-12-20 13:12:16 +01:00
Adam Reichold
a605308cee
Add change log and migration guide entries.
2023-12-20 13:07:14 +01:00
David Hewitt
bc87b7bac6
deprecate `PyTryFrom` and `PyTryInto`
2023-12-20 11:28:24 +00:00
Tpt
8b614745cf
Adds std::duration::Duration from/to Python conversions
2023-12-20 08:57:26 +01:00
Adam Reichold
416d3c488f
Rename name to qualname and full_name to name to better match Python
2023-12-19 16:51:24 +01:00
Adam Reichold
b0d4ef3525
Expand guide on async methods borrowing self.
2023-12-10 16:37:39 +01:00
Joseph Perez
e73c795967
docs: fix typos
2023-12-07 10:10:15 +01:00
David Hewitt
07726aefc4
Merge pull request #3609 from wyfo/async_receiver
...
feat: allow async methods to accept `&self`/`&mut self`
2023-12-07 07:38:25 +00:00
Joseph Perez
f34c70c2da
feat: allow async methods to accept `&self`/`&mut self`
2023-12-07 07:42:10 +01:00
David Hewitt
ed87637ebb
replace `PyTryFrom` by splitting `PyTypeInfo`
2023-12-05 08:01:30 +03:00
Joseph Perez
8a674c2bd3
feat: add `coroutine::CancelHandle`
2023-12-04 07:46:51 +01:00
David Hewitt
5c6d49084f
remove all functionality deprecated in 0.19
2023-11-27 22:02:19 +00:00
Adam Reichold
1203921d5c
Merge pull request #3456 from aldanor/feature/either
...
Add conversion support for `either::Either`
2023-11-25 09:37:49 +00:00
David Hewitt
bead83f4b0
docs: fixup docs for smallvec feature
2023-11-24 22:11:40 +00:00
Ivan Smirnov
a75464ee26
add conversion support for `either::Either`
2023-11-24 22:09:34 +00:00
Joseph Perez
627841f1e2
feat: support `async fn` in macros with coroutine implementation
2023-11-22 20:25:36 +01:00
David Hewitt
bd0174aa5d
Change return types of `py.None()`, `py.NotImplemented()` and `py.Ellipsis()` to typed singletons
2023-11-17 16:16:19 +00:00
Surya
0ff84d250e
fix missing char conversion
2023-11-10 09:27:01 -05:00
Samuel Pastva
2fbc02d06c
Finish rename
2023-10-26 19:02:06 -05:00
Samuel Pastva
fc787eabd2
Update guide/src/class.md
...
Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>
2023-10-26 18:58:43 -05:00
Samuel Pastva
48c90d9586
Add example of dynamic return type in the "Python classes" section of the guide.
2023-10-26 17:13:32 -05:00
David Hewitt
7534c31a6d
Note about `pyenv activate` and `pyenv virtualenv` commands
...
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2023-10-26 08:21:31 +01:00
David Hewitt
98346dd137
docs: improve detail around pyenv install
2023-10-25 23:29:20 +01:00
David Hewitt
2ca8e573a4
remove comparison to rust-cpython
2023-10-15 22:03:24 +01:00
David Hewitt
e1d4173827
Fix bug in default implementation of `__ne__`
2023-10-11 09:48:06 +01:00
David Hewitt
f335f42197
Merge pull request #3446 from davidhewitt/relax-import-check
...
relax multiple-import check to only prevent subinterpreters
2023-09-29 16:35:31 +00:00
SigureMo
25b2acb0eb
fix some dead links
2023-09-29 13:24:00 +08:00
David Hewitt
f17e703167
return existing module on Python 3.9 and up
2023-09-23 11:13:39 +01:00
Jeff Schwab
535a255bae
Fix a typo in a documentation page title
2023-09-21 21:11:27 +01:00
David Hewitt
bcb01049cc
Merge pull request #3404 from davidhewitt/fix-dealloc
...
call PyObject_GC_Untrack before deallocating
2023-09-11 05:18:34 +00:00
David Hewitt
e28403e772
call PyObject_GC_Untrack before deallocating
2023-09-09 22:29:58 +01:00
David Hewitt
c7f834ad87
add migration guide entry for `PyDict::get_item`
2023-09-09 13:05:51 +01:00
Julian Hofer
6e24fb6643
guide: Add `playground.runnable` = false to book.toml
2023-09-05 22:28:43 +02:00
David Hewitt
e67b283b25
Merge pull request #3358 from alex/ptr-unsafe-trait
...
fixes #3325 -- mark `AsPyPointer` as `unsafe trait`
2023-09-04 05:05:56 +00:00
David Hewitt
4c46d81afd
simplify thread checker implementation
2023-09-03 14:15:26 +01:00
David Hewitt
cc1aa598cd
Merge pull request #3411 from OliverFM/main
...
Update docs with fresher bazel example
2023-08-29 06:17:51 +00:00
oliver
9714f819f0
Update docs with fresher bazel example
2023-08-29 06:44:22 +01:00
Shahriar Heidrich
2855b9d508
Mention no subclassing of Python classes in docs
2023-08-28 12:34:13 +02:00
Alex Gaynor
df5aa77800
fixes #3325 -- mark `AsPyPointer` as `unsafe trait`
2023-08-18 10:16:34 -04:00
Adam Reichold
9363491d54
Merge pull request #3384 from DataTriny/pyclass_rename_variants
...
Add `rename_all` attribute to `#[pyclass]`
2023-08-16 19:06:37 +00:00
DataTriny
f02fe9478d
Make rename_all accept a renaming rule, allow applying it to classes as well
2023-08-15 10:15:48 +02:00
David Hewitt
5ad55d2dc7
Revert "Fix typos and other minor touchups to guide"
...
This reverts commit 24eee46128
.
2023-08-15 08:55:41 +01:00
Alex Gaynor
5061b501a9
Remove IntoPyPointer
...
it wasn't used in any public APIs following #3359
2023-08-14 16:28:20 -04:00
DataTriny
a9e9ec628d
Add attribute to
2023-08-13 18:25:07 +02:00
David Hewitt
64adab1a76
add as_ptr and into_ptr inherent methods
2023-08-11 10:49:42 +01:00
Tpt
1e5a49557d
Makes PathBuf FromPyObject implementation work on all os.PathLike
...
PyOS_FSPath is in abi3-py36
2023-08-08 22:15:56 +02:00
CallMeMSL
5bcb513add
Update outdated link in python_typing_hints.md and fix typos
2023-07-14 15:50:14 +02:00
Pan Piłkarz
f3d7cf6fac
Tiny grammar fix in error_handling.md
2023-07-12 15:51:18 +02:00
Adam Reichold
89b9bc384a
Merge pull request #3304 from PyO3/guide-perf-section
...
Start adding a performance section to the guide.
2023-07-11 19:36:56 +00:00
mejrs
092b73aa48
Two is not three
2023-07-11 13:56:34 +02:00
Adam Reichold
bedb682d0e
Add another performance subsection on implicit access to GIL token.
2023-07-09 15:02:12 +02:00
Adam Reichold
ff78b92e77
Start adding a performance section to the guide.
2023-07-09 14:32:59 +02:00
David Hewitt
23d1a6d307
add some missing type conversions to the guide
2023-07-03 21:36:17 +01:00
Alex Gaynor
0b78bb851e
Allow `#[new]` to return existing instances
...
fixes #2384
2023-07-02 19:57:53 -04:00
CallMeMSL
23bdd4337f
Fix typos and add punctuation recommended by grammarly in Class.md
2023-06-28 13:46:13 +02:00
Luca Trevisani
de9d760462
Add conversions between Rust Path/PathBuf and Python str / pathlib.Path
2023-06-25 20:40:51 +02:00
Adam Reichold
684002daf5
Format recently modified code example from the guide.
2023-06-16 12:46:26 +02:00
Adam Reichold
2996f92ade
Extend guide section on classes regarding free functions
...
It might not be obvious from the reading the sections on free functions and on
classes that they combine in a frictionless manner, i.e. class instances can be
parameters to free functions in the same manner that the self parameters of
instance methods are handled.
This also explicitly calls out the interaction between `Clone` and
`FromPyObject` for classes.
2023-06-16 08:44:34 +02:00
Adam Reichold
a0c85bb649
Merge pull request #3240 from davidhewitt/maturin-versions
...
bump maturin version in example files
2023-06-14 08:24:31 +00:00
David Hewitt
5fd5dcba44
bump maturin version in example files
2023-06-14 08:45:32 +01:00
David Hewitt
4f3fcdbf0f
remove all functionality deprecated in PyO3 0.18
2023-06-13 22:27:43 +01:00
Adam Reichold
0d30bb7d3d
Bump Rust edition to 2021 and make current Clippy happy.
2023-06-07 21:15:38 +02:00
bors[bot]
dbf7b233aa
Merge #3203
...
3203: support ordering magic methods for `#[pyclass]` r=adamreichold a=davidhewitt
Closes #2089
This adds `__lt__`, `__le__`, `__eq__`, `__ne__`, `__gt__`, and `__ge__` as per the Python implementations of what we call `__richcmp__`.
There's a UI test confirming that the user cannot implement split forms and `__richcmp__` simultaneously.
There's also a benchmark comparing implementing these split methods against using `__richcmp__`. I couldn't see a meaningful performance difference, so I'm tempted to deprecate `__richcmp__`, given that's not a magic method which exists in Python. Potentially we can provide options such as the opt-in `#[pyclass(eq, ord)]` to avoid boilerplate for people who don't want to implement six different methods.
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-06-05 07:13:23 +00:00
Adam Reichold
5738edfdd4
Bump MSRV to 1.56
2023-06-04 23:02:30 +01:00
David Hewitt
8850d5d384
support ordering magic methods for `#[pyclass]`
2023-06-04 13:58:18 +01:00
David Hewitt
2500e22e13
release: 0.19.0
2023-05-31 13:53:37 +01:00
Adam Reichold
810ad00a76
Do not apply deferred ref count updates and prevent the GIL from being acquired inside of implementations.
2023-05-25 20:01:35 +02:00
David Hewitt
248230b8e4
refactor PyAny::is_instance_of for performance
2023-05-18 22:25:27 +01:00
Adam Reichold
b9766cfa11
Add PyClass::get and Py::get for GIL-independent access to frozen classes.
2023-05-18 08:57:55 +02:00
Stu Hood
20c5618160
Add support for combining the `#[new]` and `#[classmethod]` method types.
2023-05-16 15:51:14 -07:00
bors[bot]
633b592ed5
Merge #2593
...
2593: docs: mention PyBuffer r=adamreichold a=davidhewitt
Uses PEP 688 `types.Buffer` to describe `PyBuffer<T>` in the conversion tables. Will leave as draft until PEP 688 is finalised.
Closes #954
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-05-09 20:24:37 +00:00
David Hewitt
7c231a2372
docs: mention PyBuffer
2023-05-09 19:53:39 +01:00
Adrien
1676100dfd
Added a few lines to document the main difference between maturin and setuptools-rust as far as building manylinux-compliant wheels is concerned.
...
Added newfragment
2023-05-09 14:54:30 +02:00
David Hewitt
dd24c9ea71
remove `Python::acquire_gil`
2023-05-09 09:39:23 +02:00
Adam Reichold
3c634dd9a9
Add migration guide entry on replacing acquire_gil by with_gil.
2023-05-09 09:39:23 +02:00
BlueGlassBlock
fdd43d0685
feat: unwrap dyn Err when inner is simple PyErr
2023-05-09 07:17:10 +01:00
bors[bot]
1cdac4fde4
Merge #2980
...
2980: support `text_signature` on `#[new]` r=adamreichold a=davidhewitt
Closes #2866
This is a breaking change for 0.19.0, because it starts autogenerating `text_signature` for `#[new]`. This could affect runtime behaviour if the user is relying on the class docs at runtime for some reason.
Guide & tests all updated accordingly.
`#[pyclass(text_signature = "...")]` is deprecated by this PR, however if it's set, it will be used in preference to `#[new]`.
(The signature / `text_signature` from `#[new]` will simply be ignored in this case. I figure that when users fix their deprecation warnings by removing `#[pyclass(text_signature = "...")]` then the `#[new]` signatures will start flowing properly, and this is good enough.)
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-05-04 16:51:54 +00:00
bors[bot]
6356acb2f9
Merge #3120
...
3120: feat: add #[pyo3(from_item_all)] for FromPyObject r=davidhewitt a=BlueGlassBlock
This PR addresses #3112 by implementing ~~`#[pyo3(item_all)]`~~ `#[pyo3(from_item_all)]`.
Co-authored-by: BlueGlassBlock <blueglassblock@outlook.com>
2023-05-04 07:10:21 +00:00
David Hewitt
8bd17f02c7
support `text_signature` on `#[new]`
2023-05-04 07:15:11 +01:00
cfour2
559b540b5c
Fix a crate doc link for IterNextOutput
2023-05-02 15:05:53 +08:00
BlueGlassBlock
1d6ab21781
fix: change to from_item_all
2023-04-26 19:47:07 +08:00
BlueGlassBlock
30b2ed1d85
feat: add #[pyo3(item_all)] for FromPyObject
2023-04-25 19:37:05 +08:00