Commit Graph

40 Commits

Author SHA1 Message Date
David Hewitt 0b967d427a
use `ffi::MemberGef` for `#[pyo3(get)]` fields of `Py<T>` (#4254)
* use `ffi::MemberGef` for `#[pyo3(get)]` fields of `Py<T>`

* tidy up implementation

* make it work on MSRV :(

* fix docs and newsfragment

* clippy

* internal docs and coverage

* review: mejrs
2024-06-21 23:33:34 +00:00
Icxolu 5749a08b63
ci: updates for Rust 1.79 (#4244)
* ci: updates for Rust 1.79

* ci: fix beta clippy

* ci: fix `dead_code` warning on nightly
2024-06-13 18:24:13 +00:00
Adam Reichold c5f9001985
Remove deferred reference count increments and make the global reference pool optional (#4095)
* Add feature controlling the global reference pool to enable avoiding its overhead.

* Document reference-pool feature in the performance guide.

* Invert semantics of feature to disable reference pool so the new behaviour becomes opt-in

* Remove delayed reference count increments as we cannot prevent reference count errors as long as these are available

* Adjust tests to be compatible with disable-reference-pool feature

* Adjust tests to be compatible with py-clone feature

* Adjust the GIL benchmark to the updated reference pool semantics.

* Further extend and clarify the documentation of the py-clone and disable-reference-pool features

* Replace disable-reference-pool feature by pyo3_disable_reference_pool conditional compilation flag

Such a flag is harder to use and thereby also harder to abuse. This seems
appropriate as this is purely a performance-oriented change which show only be
enabled by leaf crates and brings with it additional highly implicit sources of
process aborts.

* Add pyo3_leak_on_drop_without_reference_pool to turn aborts into leaks when the global reference pool is disabled and the GIL is not held
2024-05-11 14:48:45 +00:00
Icxolu aef0a05719
deprecate implicit default for trailing optional arguments (#4078)
* deprecate "trailing optional arguments" implicit default behaviour

* add newsfragment

* generate individual deprecation messages per function

* add migration guide entry
2024-05-10 10:34:58 +00:00
David Hewitt 351c6a0a49
deprecate optional GIL Ref in function argument (#3975) 2024-03-21 07:24:40 +00:00
David Hewitt 870a4bb20d
deprecate GIL refs in function argument (#3847)
* deprecate GIL Refs in function arguments

* fix deprecated gil refs in function arguments

* add notes on deprecations limitations to migration guide

* Apply suggestions from code review

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>

* review: Icxolu

* fix proto method extract failure for option

* fix gil refs in examples

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-03-20 22:35:08 +00:00
Icxolu 61bc02d927
deprecate `PyCell::new` in favor of `Py::new` or `Bound::new` (#3872)
* deprecate `PyCell::new` in favor of `Py::new` or `Bound::new`

* update deprecation warning

Co-authored-by: David Hewitt <mail@davidhewitt.dev>

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-20 07:45:47 +00:00
Icxolu 4ce9c35983
port `Python::get_type` to `Bound` API (#3846)
* port `Python::get_type` to `Bound` API

* fix `is_subclass_and_is_instance` FIXME
2024-02-18 18:27:19 +00:00
Lily Foote 0dd568d397
Use the new bound API instead of .as_ref(py) (#3853)
* Use the new bound API instead of .as_ref(py)

* Move import into a nested scope

* Use to_cow instead of to_str for compatibility

`to_str` is not available before Python 3.10 on the limited api.

* Relax &self lifetimes

* Use Bound<'py, PyAny> in test Mapping signatures

* Use .as_bytes(py)

* Simplify ThrowCallback::throw signature

* Avoid .as_any call with Py api instead of Bound
2024-02-18 00:09:56 +00:00
Icxolu e45fbe493c port `IntoPyDict` to `Bound` API 2024-02-10 15:47:26 +01:00
David Hewitt 7d486bb72a tests/common.rs -> src/tests/common.rs 2023-09-24 13:34:53 +01:00
David Hewitt 64adab1a76 add as_ptr and into_ptr inherent methods 2023-08-11 10:49:42 +01:00
David Hewitt dd24c9ea71 remove `Python::acquire_gil` 2023-05-09 09:39:23 +02:00
David Hewitt fd8026c7bb pyclass: add `sequence` option to implement `sq_length` 2022-08-20 07:14:26 +01:00
mejrs fc6121eafe Deprecate acquire_gil 2022-08-15 03:34:47 +02:00
Ashley Anderson 5d88e1d1c4
Update PyTryFrom for PyMapping and PySequence to more accurately check types (#2477)
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-08-10 21:03:18 +01:00
mejrs 984fdf57c7 Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
mejrs 6f1cf1b662 Add more lints 2022-03-23 08:07:28 +01:00
David Hewitt ddf13ea98f clippy: enable some more lints 2022-03-03 07:23:28 +00:00
Georg Brandl 03dc96bff1
Py/PyAny: remove PartialEq impl and add is() (#2183) 2022-02-25 19:39:45 +00:00
David Hewitt 424644181b pymethods: add support for inplace concat & repeat 2022-02-24 23:07:24 +00:00
David Hewitt 6af47c78f1 pymethods: more tests for magic methods 2022-02-16 07:42:25 +00:00
David Hewitt 558549e1c2 pyproto: split into new feature 2022-02-05 16:51:31 +00:00
David Hewitt 6433d884fc dev: remove self dev dependency 2021-12-08 07:48:58 +00:00
kngwyu 9b88a452e2 Refactor tests to use shorter macros 2021-03-14 23:43:53 +09:00
David Hewitt 9617edfca9 msrv: bump to 1.45 2020-11-12 11:33:08 +00:00
David Hewitt b9e95dc7c9 Implement std::error::Error for PyErr 2020-09-10 19:04:24 +01:00
David Hewitt 4ed9748b45 Rename exceptions to PyException etc; reintroduce deprecated ones 2020-07-18 06:02:57 +01:00
David Hewitt a9c7e12be0 Allow skipping the return type completely for `#[pyproto]` methods returning `()`. 2020-06-23 11:51:02 +01:00
David Hewitt c7a4b4770f Refactor `#[pyproto]` Result types 2020-06-23 11:08:36 +01:00
David Hewitt 29c93c87c7 Remove GetPropertyValue 2020-05-21 18:06:24 +01:00
kngwyu 02ee7a5afc Expose PyAny to lib.rs and prelude 2020-03-18 13:38:18 +09:00
kngwyu da4ed398bb Fix PyCell to share BorrowFlag with parents 2020-02-15 18:13:39 +09:00
kngwyu a6639076b9 Introduce PyInternalCaster 2019-12-14 23:16:39 +09:00
Samuele Maci 247c8b5f1c Address clippy::map_clone issues 2019-08-17 14:10:36 +02:00
Samuele Maci 1ed7460bf3 Address clippy::or_fun_call issues 2019-08-17 14:10:36 +02:00
kngwyu 0f9a3b1194 Expose py_run macro 2019-06-13 18:18:06 +09:00
Martin Larralde dfd1fa55c0 Remove dead code from `tests/test_sequence.rs` 2019-03-31 05:29:25 +02:00
Martin Larralde 3b7e83fb7c Run `cargo fmt` on `tests/test_sequence.rs` 2019-03-31 05:28:52 +02:00
Martin Larralde dd2f1ba16a Add tests for `PySequenceProtocol` in `tests/test_sequence.rs` 2019-03-31 05:28:52 +02:00