Commit Graph

706 Commits

Author SHA1 Message Date
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
xcharleslin 512847257e
Fix crate docs links in python_from_rust.md 2023-04-24 15:21:08 -07:00
Walnut 24ab144a41
minor grammar fix in documentation 2023-04-23 02:05:51 -05:00
Doug Goldstein 8e0bde14c9 implement Decimal to rust_decimal conversions
Implement conversion between rust_decimal::Decimal and decimal.Decimal
from Python's stdlib. The C API does not appear to be exposed on the
Python side so we need to call into it via Python.
2023-04-22 19:55:21 +02:00
Jonathan Daniel 3a9c6b175d
Update getting_started.md
Update Poetry command to Poetry groups syntax (1.2+).
https://python-poetry.org/docs/cli/#options-4
2023-04-21 23:19:57 +03:00
bors[bot] a0e285b497
Merge #3066 #3098
3066: Improve default value for `None` in `text_signature` r=davidhewitt a=messense

xref #2863

3098: readme: add new pyo3 article r=adamreichold a=davidhewitt

With thanks to `@ohadravid` for the great piece!

Co-authored-by: messense <messense@icloud.com>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-04-12 07:40:50 +00:00
David Hewitt 80d95f9134 docs: fix migration guide entry for pyproto 2023-04-11 21:23:05 +01:00
Adam Reichold 48f79718f9 Fix redundant imports in doc tests thereby fixing the careful CI job. 2023-04-10 08:09:06 +02:00
Will Jones 52a0378e56 docs: show pattern for self.__class__.__name__ in __repr__
Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>
2023-03-30 10:59:41 +02:00
messense 57dbc94293
Improve default value for `None` in `text_signature` 2023-03-29 10:14:44 +08:00
bors[bot] ebedcfb8b2
Merge #3050
3050: Improve default values for str, numbers and bool in `text_signature` r=davidhewitt a=messense

xref #2863

Co-authored-by: messense <messense@icloud.com>
2023-03-25 07:07:06 +00:00
bors[bot] e5e8c7a6d0
Merge #2975 #3022 #3023
2975: RFC: Add GILProtected synchronization primitive and use it for LazyTypeObjectInner. r=davidhewitt a=adamreichold

I would also like to use that type in rust-numpy and it seems we can avoid ~~both a manual unsafe impl and~~ a full blown mutex if we apply it to `LazyTypeObjectInner`.

One downside might be that it ties us closer to the GIL when we want to enable nogil experimentation, but on the other hand, it may also help by reifying the GIL usage. (This is currently limited to comments in unsafe code in rust-numpy for example.)

3022: Fix function name shadowing r=davidhewitt a=mejrs

Fixes https://github.com/PyO3/pyo3/issues/3017

3023: Emit a better error for bad argument names r=davidhewitt a=mejrs

This will emit a better error for code like 
```rust
#[pyfunction]
fn output([a,b,c]: [u8;3]) {}
```



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
Co-authored-by: mejrs <59372212+mejrs@users.noreply.github.com>
2023-03-23 08:04:11 +00:00
messense 79a70f3923
Improve default values for str, numbers and bool in `text_signature` 2023-03-16 11:06:51 +08:00
Adrian Garcia Badaracco 626a67ca49 Add note about garbage collection on PyPy 2023-03-12 23:35:47 +00:00
Antoine Romero-Romero a629e8267a feat: add #[pyo3(get, set)] for Cell 2023-03-09 23:09:30 +00:00
bors[bot] 410bb15d71
Merge #2982
2982: explain STATUS_DLL_NOT_FOUND r=adamreichold a=mejrs

I had someone ask me this today, and googling for it I found various other places where this was asked, with no (good) answers. 

Co-authored-by: mejrs <59372212+mejrs@users.noreply.github.com>
2023-02-24 17:13:38 +00:00
mejrs db16580b63 Make changes 2023-02-23 12:36:54 +01:00
Adam Reichold 9534749d8b Add GILProtected synchronization primitive replacement and use it for LazyTypeObjectInner. 2023-02-23 09:38:02 +01:00
mejrs 90ce52175f explain STATUS_DLL_NOT_FOUND 2023-02-22 23:30:19 +01:00
Adam Reichold a16f2e45c8 Include conversions for bytes, bytearrays and Cow<[u8]> in the guide. 2023-02-22 22:07:59 +01:00
Azat Ibrakov 9f7368922f docs: fix typo in method name 2023-02-18 22:02:05 +01:00
David Hewitt c7cc48f8e4 use PyO3 types within LazyTypeObject 2023-02-18 09:06:36 +00:00
David Hewitt 00ddd21535 change PyModule::add_class to return an error if class creation fails 2023-02-14 22:08:35 +00:00
David Hewitt dbeb3b4453 move some private internals out of public implementation 2023-02-11 21:28:27 +00:00
bors[bot] 9e5c845dee
Merge #2934
2934: guide: add documentation for trailing option arguments r=davidhewitt a=davidhewitt

Following the increased clarity around PyO3's handling of function signatures of 0.18.0, I wanted to add a section to the guide documenting the default-to-none behaviour for trailing `Option<T>` arguments.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-02-07 08:15:57 +00:00
Jeff Hodges bc1a33f9fe
bump maturin version in getting_started.md
Latest maturin is 0.14.x
2023-02-04 00:09:04 -08:00
Julien Jerphanion 9306d56b27 docs: Precise the abscense of `py: Python` for the #[pyo3(signature)] 2023-02-03 20:57:23 +00:00
David Hewitt c709f30638 guide: add documentation for trailing option arguments 2023-02-03 20:54:51 +00:00
David Hewitt e83803e813 add link on how to obtain GIL to guide 2023-01-20 08:21:57 +00:00
David Hewitt 586fed2c4b send errors in `__releasebuffer__` to `sys.unraisablehook` 2023-01-19 19:10:06 +00:00
David Hewitt ca1bbe3d39 add migration notes for PyO3 0.18 2023-01-17 08:14:32 +00:00
David Hewitt 20ca3be659 inspect: gate behind `experimental-inspect` feature 2023-01-15 12:41:23 +00:00
David Hewitt eea2a31bd3 adjust location and wording for extension module memory management 2023-01-10 07:42:39 +00:00
Haixuan Xavier Tao 8af9d2a19a Add a section on memory management for `extension`
Adding a special case of memory management when writing an extension.

This is a documentation of: https://github.com/PyO3/pyo3/issues/1056 and https://github.com/PyO3/pyo3/issues/2853
2023-01-10 07:37:21 +00:00
David Hewitt 8651d3b0e8 address feedback in review #2678 2023-01-06 08:53:00 +00:00
James Welchman e52dbc907d GH-2649 example for inserting moulde in sys.dict 2023-01-05 21:26:47 +00:00