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

Support for SmallVec in conversion traits #3440

Closed
jakelishman opened this issue Sep 7, 2023 · 2 comments · Fixed by #3507
Closed

Support for SmallVec in conversion traits #3440

jakelishman opened this issue Sep 7, 2023 · 2 comments · Fixed by #3507

Comments

@jakelishman
Copy link
Contributor

Would the PyO3 project be interested in a PR that adds a smallvec feature (akin to hashbrown and indexmap) to add conversion traits for the smallvec crate? In some of the higher-performance places I'm using PyO3 I'm moving some structures to smallvec for better cache locality, and at the moment I need to manually convert whenever one of those objects appears at the Python API boundary.

I'd be happy to contribute the PR, if it's a feature you'd like to merge. I don't know how you feel about expanding the optional trait implementations to every crate under the sun, though!

@davidhewitt
Copy link
Member

That'd be fine by me.

@davidhewitt
Copy link
Member

davidhewitt commented Sep 16, 2023

Given we have to provide trait implementations here, or thirdparty crates need to provide implementations (or we need to come up with a way to allow downstream implementations to register conversions at runtime, though I think that way lies dragons)...

It's probably more practical for us to maintain the conversions here rather than ask N crates to have PyO3 features (you can imagine they then have to support M language binding features).

So the bar for what crates to accept needs to be pretty high; so far we've done this case-by-case as long as they're relatively core ecosystem crates which have types which map well onto Python types.


The only cost at the moment of not accepting a crate is that all users downstream just have to wrap in newtypes or use #[pyo3(from_py_with)], so it's not that hard for users to deal with crates not integrated directly with PyO3.

orhun added a commit to orhun/pyo3 that referenced this issue Oct 11, 2023
orhun added a commit to orhun/pyo3 that referenced this issue Oct 11, 2023
orhun added a commit to orhun/pyo3 that referenced this issue Oct 11, 2023
orhun added a commit to orhun/pyo3 that referenced this issue Oct 11, 2023
orhun added a commit to orhun/pyo3 that referenced this issue Oct 11, 2023
github-merge-queue bot pushed a commit that referenced this issue Oct 15, 2023
Add support for `SmallVec` in conversion traits (#3440)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants