Commit Graph

881 Commits

Author SHA1 Message Date
Cheuk Ting Ho 81ba9a8cd5
Include import hook in getting-started.md (#4198) 2024-05-21 18:24:06 +00:00
David Hewitt 3e4b3c5c52
docs: attempt to clarify magic methods supported by PyO3 (#4190)
* docs: attempt to clarify magic methods supported by PyO3

* Update guide/src/class/protocols.md

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

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-05-19 20:13:11 +00:00
David Hewitt ac273a1612
docs: minor updates to pyenv installs (#4189) 2024-05-19 13:39:29 +00:00
newcomertv 88f2f6f4d5
feat: support pyclass on tuple enums (#4072)
* feat: support pyclass on tuple enums

* cargo fmt

* changelog

* ruff format

* rebase with adaptation for FnArg refactor

* fix class.md from pr comments

* add enum tuple variant getitem implementation

* fmt

* progress toward getitem and len impl on derive pyclass for complex enum tuple

* working getitem and len slots for complex tuple enum pyclass derivation

* refactor code generation

* address PR concerns
- take py from function argument on get_item
- make more general slot def implementation
- remove unnecessary function arguments
- add testcases for uncovered cases including future feature match_args

* add tracking issue

* fmt

* ruff

* remove me

* support match_args for tuple enum

* integrate FnArg now takes Cow

* fix empty and single element tuples

* use impl_py_slot_def for cimplex tuple enum slots

* reverse erroneous doc change

* Address latest comments

* formatting suggestion

* fix :
- clippy beta
- better compile error (+related doc and test)

---------

Co-authored-by: Chris Arderne <chris@translucent.app>
2024-05-17 02:59:00 +00:00
Icxolu 10152a7078
feature gate `PyCell` (#4177)
* feature gate `PyCell`

* feature gate `HasPyGilRef` completely

* bump version
2024-05-12 18:30:08 +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 444be3bafa
feature gate deprecated APIs for `Python` (#4173) 2024-05-10 18:28:30 +00:00
Icxolu 1e8e09dce3
feature gate `as/into_gil_ref` APIs (Part 3) (#4172) 2024-05-10 17:03:57 +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
Alex Gaynor 104328ce14
feature gate deprecated more APIs for `Py` (#4169) 2024-05-10 05:54:08 +00:00
Icxolu 21c02484d0
feature gate APIs using `into_gil_ref` (Part 2) (#4166) 2024-05-09 22:21:48 +00:00
Icxolu 7beb64a8ca
allow constructor customization of complex enum variants (#4158)
* allow `#[pyo3(signature = ...)]` on complex enum variants to specify constructor signature

* rename keyword to `constructor`

* review feedback

* add docs in guide

* add newsfragment
2024-05-09 21:08:23 +00:00
David Matos 2d19b7e2a7
Add `num-rational` support for Python's `fractions.Fraction` type (#4148)
* Add `num-rational` support for Python's `fractions.Fraction` type

* Add newsfragment

* Use Bound instead

* Handle objs which atts are incorrect

* Add extra test

* Add tests for wasm32 arch

* add type for wasm32 clipppy
2024-05-09 15:37:53 +00:00
Icxolu 72be1cddba
emit `cargo:rustc-check-cfg=CHECK_CFG` for `pyo3`s config names (#4163) 2024-05-08 05:46:00 +00:00
Heran Lin c10c7429d8
docs: Remove out-dated information for pyenv (#4138) 2024-05-04 07:32:27 +00:00
Alex Gaynor f3ab62cb7e
feature gate deprecated APIs for `PyModule` (#4151) 2024-05-03 17:10:49 +00:00
Icxolu dc9a41521a
feature gate deprecated APIs for `Py` (#4142) 2024-05-01 10:57:03 +00:00
Icxolu 2f3a33fda1
feature gate deprecated APIs for `PyList` (#4127) 2024-04-30 22:00:31 +00:00
Icxolu d5452bcd8d
feature gate deprecated APIs for `PyType`, `PyTypeInfo` and `PySuper` (#4134) 2024-04-28 21:03:51 +00:00
Alex Gaynor 9e1960ea34
Update MSRV to 1.63 (#4129)
* Bump MSRV to 1.63

* Drop parking_lot in favor of std::sync

* Make portable-atomic dep conditional

* Remove no longer required cfg
2024-04-28 16:11:28 +00:00
Alex Gaynor 8ff5e5b0ab
Fix lychee for guide (#4130)
* Fix lychee for guide

* Update nightly in netlify
2024-04-27 05:12:11 +00:00
Alexander Clausen 3cb286e0d2
docs: fix typo in trait-bounds.md (#4124) 2024-04-25 15:36:29 +00:00
Adam Reichold 4e5167db42
Extend guide on interaction between method receivers and lifetime elision. (#4069) 2024-04-13 07:57:13 +00:00
Jeong, Heon 47f9ef4174
Fix typo (#4052)
Fix incorrect closing brackets
2024-04-11 21:07:56 +00:00
David Hewitt 8cabd2619c
docs: updates to guide for PyO3 0.21 feedback (#4031)
* docs: add notes on smart pointer conversions

* guide: add more notes on `.extract::<&str>()` to migration guide
2024-04-01 15:18:57 +00:00
Weijie Guo 3af9a1f4e0
docs: fix example in types.md (#4028) 2024-03-31 08:03:38 +00:00
Rikus Honey 4d033c4497
Fix broken hyperlink to types.md (#4018) 2024-03-30 07:39:00 +00:00
geo7 0e093a5911
Update getting-started.md (#4004)
Missing word
2024-03-29 22:45:47 +00:00
David Hewitt 990886efda
docs: better document `FromPyObject` for `&str` changes in migration guide (#3974)
* docs: better document `FromPyObject` for `&str` changes in migration guide

* review: LilyFoote
2024-03-22 22:16:28 +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
David Hewitt e29fac9c46
docs: use details to condense migration guide (#3961) 2024-03-19 08:59:05 +00:00
David Hewitt dcba984b51
deprecate `GILPool` (#3947)
* deprecate `GILPool`

* review: adamreichold

* fix deprecation warnings in tests
2024-03-15 10:25:27 +00:00
Thomas Tanon 7cde95bba4
Documents experimental-declarative-modules feature (#3953)
* Documents experimental-declarative-modules feature

* More details on experimental-declarative-modules progress
2024-03-12 22:57:31 +00:00
Icxolu ee89b2e8e2
deprecate `wrap_pyfunction` with `py` argument (#3954)
* deprecate `wrap_pyfunction` with `py` argument

The Python token in `wrap_pyfunction` is not handled automatically by
`WrapPyFunctionArg`, for backwards compatibility. This uses deref
specialization to deprecate this variant.

* merge `Extractor`s

* add deprecation ui test, revert closure variant due to test failure

* fix nightly
2024-03-12 22:57:03 +00:00
acceptacross 93323bc922
chore: remove repetitive words (#3950)
Signed-off-by: acceptacross <csqcqs@gmail.com>
2024-03-11 10:15:03 +00:00
David Hewitt 9145fcfe19
docs: major rewrite for Bound API (#3906)
* wip bound docs

* Update guide/src/python_from_rust/calling-existing-code.md

Co-authored-by: Lily Foote <code@lilyf.org>

* continue to move and tidy up

* Apply suggestions from code review

Co-authored-by: Lily Foote <code@lilyf.org>

* update URL

* complete python-from-rust.md

* progress on types.md; probably more to go

* update doctest paths

* review: Icxolu

* finish updating `types.md` to Bound API

* update remainder of the guide to Bound API

* Update guide/src/performance.md

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

* Update guide/src/types.md

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

* Update src/lib.rs

* review: Icxolu

* Update guide/src/python-from-rust.md

Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>

* Update guide/src/async-await.md

Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>

* review: adamreichold

---------

Co-authored-by: Lily Foote <code@lilyf.org>
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>
2024-03-10 15:51:51 +00:00
David Hewitt 75af678f43
docs: use kebab-case instead of snake_case for guide URLs (#3942)
* guide: use kebab-case instead of snake_case

* fixup doctest names

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

* review: Icxolu

* fix relative url

* also remap latest pyo3

* fixup python_from_rust

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-03-09 20:10:58 +00:00
David Hewitt 14d1d2a9ee
docs: use `lychee` to check link URLs (#3941)
* guide: install `mdbook-linkcheck`

* use `shutil` to copy license files

* move from `mdbook-linkcheck` to `lychee`

* clean guide & doc build products before build

* fix more broken links

* review: mejrs
2024-03-08 14:10:47 +00:00
David Hewitt 770d9b7f01
add `FromPyObjectBound` trait for extracting `&str` without GIL Refs (#3928)
* add `FromPyObjectBound` adjustment for `&str` without GIL Refs

* review: alex, Icxolu feedback

* add newsfragment

* add newsfragment for `FromPyObject` trait change

* make some examples compatible with abi3 < 3.10

* seal `FromPyObjectBound`

* fixup chrono_tz conversion
2024-03-08 07:43:48 +00:00
Icxolu 31c4820010
deprecate `&PyModule` as `#[pymodule]` argument type (#3936)
* deprecate `&PyModule` as `#[pymodule]` argument type

* cleanup

* add ui tests

* fix deprecations in tests

* fix maturin and setuptools-rust starters

* run `deprecated` ui test only when `gil-refs` as disabled
2024-03-08 00:28:11 +00:00
David Hewitt 57bbc32e7c
add `experimental-async` feature (#3931)
* add `experimental-async` feature

* gate async doctests on feature
2024-03-06 00:54:45 +00:00
Icxolu 70a7aa808d
deprecate the use of `PyCell` in favor of `Bound` and `Py` (#3916)
* deprecate the use of `PyCell` in favor of `Bound` and `Py`

* update `FromPyObject` for `T: PyClass + Clone` impl

* move `PyCell` deprecation to the `gil-refs` feature gate and add a migration note
2024-03-03 14:47:25 +00:00
Icxolu 00eb014623
docs: update Python function section of the guide (#3925)
* docs: update Python function section of the guide

* update `pass_module` types

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

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-03-03 09:15:46 +00:00
Icxolu 81be11e67a
docs: update Python modules section of the guide (#3924) 2024-03-02 22:55:05 +00:00
Icxolu 1d224610c3
docs: update `Python classes` section of the guide (#3914)
* docs: update `Python classes` section of the guide

* review feedback davidhewitt

* migration guide entry
2024-03-01 09:21:47 +00:00
Lily Foote 56683ed553
deprecate Py::as_ref (#3864)
* Deprecate Py::as_ref

* Reword as_ref deprecation note

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

* Tidy up remaining uses of Py::as_ref

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

* Pass hello into println! explicitly

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-29 07:15:34 +00:00
Matthew Neeley 68ec6de0c9
Use single-arg form of `#[pymodule]` function in docs and tests (#3899)
* Use single-arg form for `#[pymodule]` functions in docs and tests

* Update guide/src/function.md

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

* Add test of two-argument module function

* Fix new test

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-02-28 22:36:50 +00:00
David Hewitt a582fa0163
docs: update discord invite to permanent one (#3913) 2024-02-28 20:51:40 +00:00
David Hewitt 8a12970c96
update `extract_argument` to use Bound APIs (#3708)
* update `extract_argument` to use `Bound` APIs

* tidy up borrow in macros expression

* update `trybuild` output

* more concise form for `DowncastError::new`

Co-authored-by: Lily Foote <code@lilyf.org>

* use `Borrowed` instead of newtype

* use `Borrowed::from_ptr` methods in extract_argument

* update UI tests

* avoid double-negative `#[cfg]` clauses

Co-authored-by: Lily Foote <code@lilyf.org>

* review: LilyFoote, Icxolu feedback

---------

Co-authored-by: Lily Foote <code@lilyf.org>
2024-02-28 19:36:20 +00:00