Commit Graph

5160 Commits

Author SHA1 Message Date
Adam Reichold f981fded3f Actually set target when running Clippy builds. 2023-04-14 18:41:45 +02:00
bors[bot] 61ef8fec4f
Merge #3103
3103: update release notes for 0.18.3 r=davidhewitt a=davidhewitt



Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-04-13 21:49:01 +00:00
David Hewitt bfcc1f8c27 update release notes for 0.18.3 2023-04-13 22:47:55 +01: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 4f34f0e094 readme: add new pyo3 article 2023-04-12 07:55:24 +01:00
bors[bot] b2e10f5e85
Merge #3096
3096: docs: fix migration guide entry for pyproto r=adamreichold a=davidhewitt

A sort of follow-up to #3082 .

While I don't think we need to pander to training limitations of various LLMs, I did notice that I erroneously referred to a nonexistent trait `PyBasicProtocol`, which I believe should have been [`PyObjectProtocol`](https://docs.rs/pyo3/0.15.2/pyo3/class/basic/trait.PyObjectProtocol.html).

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-04-12 06:53:58 +00:00
David Hewitt 80d95f9134 docs: fix migration guide entry for pyproto 2023-04-11 21:23:05 +01:00
bors[bot] b4d4904d71
Merge #3087
3087: PEP 623: wstr, wstr_length, state changes r=adamreichold a=ijl

https://peps.python.org/pep-0623/

	Following members are removed from the Unicode structures:

	    wstr
	    wstr_length
	    state.compact
	    state.ready

Note state.compact is still present as of v3.12.0a7.

state.interned has changed width from 2 to 1 bits.

Co-authored-by: ijl <ijl@mailbox.org>
2023-04-11 14:04:16 +00:00
ijl 88b46a7029 PEP 623: wstr, wstr_length, state changes
https://peps.python.org/pep-0623/

	Following members are removed from the Unicode structures:

	    wstr
	    wstr_length
	    state.compact
	    state.ready

Note state.compact is still present as of v3.12.0a7.

state.interned has changed width from 2 to 1 bits.
2023-04-11 12:51:42 +00:00
bors[bot] 275e66112d
Merge #3088
3088: Define _PyDict_Contains_KnownHash() FFI for CPython 3.10 or later r=messense a=ijl



Co-authored-by: ijl <ijl@mailbox.org>
2023-04-10 08:11:28 +00:00
bors[bot] 579d510916
Merge #3092
3092: Fix redundant imports in doc tests thereby fixing the careful CI job. r=adamreichold a=adamreichold



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-04-10 06:35:47 +00:00
Adam Reichold 48f79718f9 Fix redundant imports in doc tests thereby fixing the careful CI job. 2023-04-10 08:09:06 +02:00
ijl 6ee2174fec Define _PyDict_Contains_KnownHash() FFI for CPython 3.10 or later 2023-04-09 14:36:42 +00:00
bors[bot] 77fc6e6734
Merge #3067
3067: docs: show pattern for self.__class__.__name__ in __repr__ r=adamreichold a=wjones127

It took me a little while to figure out this pattern in PyO3, so I thought it would be a good addition to the guide.

It's not the cleanest pattern, so would welcome suggestions on how to make it shorter or easier.

Co-authored-by: Will Jones <willjones127@gmail.com>
2023-03-30 09:00:31 +00: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] 90d50da506
Merge #3071
3071: fix typo DateType -> DateTimeType, fixes #3069 r=adamreichold a=sollyucko

This should fix #3069 AKA https://stackoverflow.com/questions/75857300/tell-if-object-isinstance-of-pydatetime-or-pydate. I've added an entry in newsfragments and I've added some regression tests in test_datetime.rs.

Co-authored-by: Solomon Ucko <solly.ucko@gmail.com>
2023-03-28 16:46:42 +00:00
Solomon Ucko 7e2f732d7a fix typo DateType -> DateTimeType, fixes #3069 2023-03-28 18:45:39 +02:00
bors[bot] ba6261c8e7
Merge #3015
3015: Implement wrapper for `PyASCIIObject.state` bitfield accesses r=davidhewitt a=decathorpe

This is a first draft of my attempt to fix #1824 "properly" by writing a C wrapper for the `PyASCIIObject.state` bitfield accesses, as proposed here: https://github.com/PyO3/pyo3/issues/1824#issuecomment-1406909504

---

The original argument for making these functions `unsafe` is still valid, though - bitfield memory layout is not guaranteed to be stable across different C compilers, as it is "implementation defined" in the C standard. However, short of having CPython upstream provide non-inlined public functions to access this bitfield, this is the next best thing, as far as I can tell.

I've removed the `#[cfg(target_endian = "little")]` attributes from all things that are un-blocked by fixing this issue on big-endian systems, except for three tests, which look like expected failures considering that they do not take bit/byte order into account (for example, when writing to the bitfield).

- `ffi::tests::ascii_object_bitfield`
- `types::string::tests::test_string_data_ucs2_invalid`
- `types::string::tests::test_string_data_ucs4_invalid`

All other tests now pass on both little-endian and big-endian systems.

---

I am aware that some parts of this PR are probably not in a state that's acceptable for merging as-is, which is why I'm filing this as a draft. Feedback about how to better integrate this change with pyo3-ffi would be great. :)

In particular, I'm unsure whether the `#include` statements in the C files are actually correct across different systems. I have only tested this on Fedora Linux so far.

I'm also open to changing the names of the C functions that are implemented in the wrapper. For now I chose the most obvious names that shouldn't cause collisions with other symbols.

Co-authored-by: Fabio Valentini <decathorpe@gmail.com>
2023-03-28 07:27:02 +00:00
bors[bot] d2c6873c0f
Merge #3072
3072: CI: Pin `inventory` to `0.3.4` in MSRV job r=davidhewitt a=messense

Newer `inventory` requires `ctor` 0.2.0.

Co-authored-by: messense <messense@icloud.com>
2023-03-28 05:20:41 +00:00
messense 368664c731
CI: Pin `inventory` to `0.3.4` in MSRV job 2023-03-28 13:09:58 +08:00
Fabio Valentini 40d6d4797f
Add wrapper for PyASCIIObject state bitfield accesses based on bindgen 2023-03-26 17:11:01 +02: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] e2bcca4771
Merge #3063
3063: update release notes for 0.18.2 r=davidhewitt a=davidhewitt

Changelog entry & cargo.toml changes from 0.18.2 

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-24 21:44:48 +00:00
David Hewitt e7e58ba51e update release notes for 0.18.2 2023-03-24 20:40: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
mejrs 1ecc71638d Emit a better error for bad argument names 2023-03-23 07:43:54 +00:00
mejrs 4966d93494 Fix function name shadowing 2023-03-23 07:33:14 +00:00
bors[bot] 28814f2978
Merge #3055
3055: Fix compile error when trying to use static slot methods, fixes: #3039 r=davidhewitt a=willstott101

Whilst having static slot methods is of dubious value in the first place, there's little reason not to support it by bringing the different function call macros more in-line with each other.

I had no idea which test file to use so I just made a new one... `test_methods.rs` has no slots in and the test files that do use slots seem to be specific to their protocol. Let me know if you'd like the test somewhere else.

Thanks!

Co-authored-by: Will Stott <willstott101@gmail.com>
2023-03-23 07:23:38 +00:00
bors[bot] ebd417c9cc
Merge #3044
3044: Add `PyTuple::to_list` r=davidhewitt a=davidhewitt

Companion to #3043. I've included benchmarks which suggests that this method is indeed about 25% faster on my machine.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-18 21:43:37 +00:00
bors[bot] 86b88d0088
Merge #3056
3056: ci: pin syn to 1.0 for MSRV r=davidhewitt a=davidhewitt

Looks like syn 2.0 requires Rust 1.56 - it'll be interesting for us to update to this one day, but not quite yet!

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-18 21:03:22 +00:00
David Hewitt 91afc7dc89 ci: pin syn to 1.0 for MSRV 2023-03-18 20:50:24 +00:00
David Hewitt 2c11b25fee Add `PyTuple::to_list` 2023-03-18 14:44:45 +00:00
Will Stott b05795307c Test static __getitem__ as well as __len__ 2023-03-18 13:56:51 +00:00
Will Stott bcdb17db5b Fix compile error when trying to use static slot methods 2023-03-18 11:16:52 +00:00
messense 79a70f3923
Improve default values for str, numbers and bool in `text_signature` 2023-03-16 11:06:51 +08:00
bors[bot] 658bc6bb7c
Merge #3049
3049: Add Blog post in Articles and other media section  r=messense a=AdilZouitine

Hi there 👋,

This pull request adds a link to a blog post in the PyO3 README under the "Articles and other media" section. The blog post, titled "How we extended the River stats module with Rust using PyO3," details our experience in utilizing PyO3 to improve the performance of the River library's stats module.




Co-authored-by: Adil Zouitine <adilzouitinegm@gmail.com>
2023-03-15 23:31:20 +00:00
Adil Zouitine bb9c54c09b
Update README.md
Add How we extended the River stats module with Rust using PyO3 blog post
2023-03-15 14:18:06 +01:00
bors[bot] b711e983ba
Merge #3040
3040: mangle exported functions for PyPy r=adamreichold a=mattip

Continuation of #3031. This [turned up](https://github.com/pypy/binary-testing/actions/runs/4390086363/jobs/7688256133#step:6:179) in the run of PyPy 3.10 HEAD against PyO3 HEAD. Should I add a new news fragment or is the one from #3031 sufficient?

Co-authored-by: Matti Picus <matti.picus@gmail.com>
2023-03-15 09:53:08 +00:00
Matti Picus a7cc5952c7
Conditionally mangle the function name
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-14 09:21:35 +11:00
bors[bot] 2823ab3944
Merge #3038
3038: Add note about garbage collection on PyPy r=davidhewitt a=adriangb

Closes #3005

Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
2023-03-12 23:36:35 +00:00
Adrian Garcia Badaracco 626a67ca49 Add note about garbage collection on PyPy 2023-03-12 23:35:47 +00:00
bors[bot] 11c8d0efe7
Merge #3043
3043: `PyList::as_tuple()` -> `PyList::to_tuple()` r=mejrs a=davidhewitt

As discussed as a follow-up to #3042 

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-12 22:02:37 +00:00
David Hewitt d3f5fed416 `PyList::as_tuple()` -> `PyList::to_tuple()` 2023-03-12 16:27:15 +00:00
bors[bot] 30521c853d
Merge #3042
3042: add `as_tuple()` method to `PyList` r=davidhewitt a=samuelcolvin

From [benchmarks](25fcf98e12/benches/main.rs (L165-L192)), this is significantly faster than `PyTuple::new(py, the_list)`:

```
test list_as_tuple_direct        ... bench:         299 ns/iter (+/- 51)
test list_as_tuple_iterate       ... bench:         521 ns/iter (+/- 41)
```


Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2023-03-12 13:56:01 +00:00
Samuel Colvin a6c2695c7f
revert .gitignore change 2023-03-12 13:54:06 +00:00
Samuel Colvin b388f79a5f
add fragment 2023-03-12 12:46:59 +00:00
Samuel Colvin bf500edd16
add as_tuple() method to PyList 2023-03-12 12:42:59 +00:00
Matti Picus 0f1ff1d852 mangle exported functions for PyPy 2023-03-12 08:40:12 +11:00
bors[bot] 4b0b9b91a3
Merge #3036
3036: fix const-ness of some FFI name & doc members r=adamreichold a=davidhewitt

I just noticed that these are [`*const` since Python 3.7](007d7ff73f (diff-830b405713d1c40982ffa918864e39c40c1b318d79b8dd2b523646dc3bd18b52)).

This might break existing compiles, so will not include this in 0.18.2.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-10 17:12:15 +00:00