Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uuid python convertions #4836

Closed
wants to merge 19 commits into from

Conversation

JeanArhancet
Copy link
Contributor

Add conversions to/from UUID #4365

@JeanArhancet
Copy link
Contributor Author

I'm currently stuck on the issue with the tests and I'm not sure how to fix the code for the error in tests/ui/invalid_pyfunctions.rs https://github.com/PyO3/pyo3/actions/runs/12611322513/job/35146860900?pr=4836$

@Icxolu
Copy link
Contributor

Icxolu commented Jan 15, 2025

To bless the ui tests, you can either run nox -s update-ui-tests or set TRYBUILD=overwrite env variable while running the tests. This will update the corresponding stderr file.

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Couple of initial thoughts...

Comment on lines 88 to 89
} else if let Ok(py_bytearray) = obj.downcast::<PyByteArray>() {
&py_bytearray.to_vec()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we might want to stay away from Bytearray::to_vec (see #4736). Maybe for the moment just avoid byte arrays? Or maybe we want to go through the buffer protocol? That's not really much better 🤔


fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
let uuid_cls = get_uuid_cls(py)?;
let kwargs = [("int", self.as_u128())].into_py_dict(py)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are much more efficient calling as positional arguments, it might be worth benchmarking that here. (I guess the tuple would be something like (None, None, None, None, int).)

Tpt and others added 18 commits January 17, 2025 19:53
* Fix struct layouts on GraalPy

* Add changelog item
* fix: cross-compilation compatibility checks for Windows

* add newsfragments

* add simple test
* Expand docs on when and why allow_threads is necessary

* spelling

* simplify example a little

* use less indirection in the example

* Update guide/src/parallelism.md

* Add note about the GIL preventing parallelism

* Update guide/src/free-threading.md

Co-authored-by: Bruno Kolenbrander <[email protected]>

* pared down text about need to use with_gil

* rearrange slightly

---------

Co-authored-by: Bruno Kolenbrander <[email protected]>
* clarify safety docs for PyDict API

* get dict size using PyDict_Size on free-threaded build

* avoid unnecessary critical sections in PyDict

* add changelog entry

* fix build error on GIL-enabled build

* address code review comments

* move attribute below doc comment

* ignore unsafe_op_in_unsafe_fn in next_unchecked

---------

Co-authored-by: David Hewitt <[email protected]>
* implement locked iteration for PyList

* fix limited API and PyPy support

* fix formatting of safety docstrings

* only define fold and rfold on not(feature = "nightly")

* add missing try_fold implementation on nightly

* Use split borrows for locked iteration for PyList

Inline ListIterImpl implementations by using split borrows and
destructuring let Self { .. } = self destructuring inside
BoundListIterator impls.

Signed-off-by: Manos Pitsidianakis <[email protected]>

* use a function to do the split borrow

* add changelog entries

* fix clippy on limited API and PyPy

* use a macro for the split borrow

* add a test that mutates the list during a fold

* enable next_unchecked on PyPy

* fix incorrect docstring for locked_for_each

* simplify borrows by adding BoundListIterator::with_critical_section

* fix build on GIL-enabled and limited API builds

* fix docs build on MSRV

---------

Signed-off-by: Manos Pitsidianakis <[email protected]>
Co-authored-by: Manos Pitsidianakis <[email protected]>
@JeanArhancet
Copy link
Contributor Author

I made a mistake with my Git manipulations; I'll open another PR, sorry

@bschoenmaeckers
Copy link
Contributor

You can also force push to this branch to fix your mistake without having to open a second PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.