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 conversion support for either::Either #3456

Merged
merged 1 commit into from Nov 25, 2023

Conversation

aldanor
Copy link
Contributor

@aldanor aldanor commented Sep 16, 2023

Added conversion support for either's Either<L, R> type, equivalent to Union[L, R] on the Python side.

It's a tiny but pretty popular crate, with 24k dependent crates and 6-7M downloads/m.

It also simplifies a very common use case of accepting or returning one of the two types, without having to define a helper enum for each particular case.

aldanor added a commit to aldanor/pyo3 that referenced this pull request Sep 16, 2023
aldanor added a commit to aldanor/pyo3 that referenced this pull request Sep 16, 2023
@aldanor
Copy link
Contributor Author

aldanor commented Sep 16, 2023

Btw the errors that appear on CI:

---- conversions::chrono::tests::test_pyo3_time_frompyobject stdout ----
thread 'conversions::chrono::tests::test_pyo3_time_frompyobject' panicked at 'called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'ValueError'>, value: ValueError('invalid or out-of-range time'), traceback: None }', src/conversions/chrono.rs:833:60

I was also seeing locally (on M1), was assuming it's some local problem, but apparently not...

@adamreichold
Copy link
Member

adamreichold commented Sep 16, 2023

I was also seeing locally (on M1), was assuming it's some local problem, but apparently not...

You might be seeing fallout from #3424.

aldanor added a commit to aldanor/pyo3 that referenced this pull request Sep 16, 2023
@davidhewitt
Copy link
Member

Yes I'm working on a pr to fix the chrono problem, will try to push later

@davidhewitt davidhewitt added this to the 0.21 milestone Nov 19, 2023
davidhewitt pushed a commit to aldanor/pyo3 that referenced this pull request Nov 24, 2023
Copy link

codspeed-hq bot commented Nov 24, 2023

CodSpeed Performance Report

Merging #3456 will improve performances by 22.57%

Comparing aldanor:feature/either (a75464e) with main (31b871a)

Summary

⚡ 1 improvements
✅ 77 untouched benchmarks

Benchmarks breakdown

Benchmark main aldanor:feature/either Change
list_via_extract 301.7 ns 246.1 ns +22.57%

@adamreichold adamreichold added this pull request to the merge queue Nov 25, 2023
Merged via the queue into PyO3:main with commit 1203921 Nov 25, 2023
35 of 36 checks passed
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.

None yet

3 participants