-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: Support optimised init from non-dict Mapping objects in from_records and frame/series constructors
#22638
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
Merged
ritchie46
merged 2 commits into
pola-rs:main
from
alexander-beedie:init-from-non-dict-mapping-objs
May 12, 2025
Merged
feat: Support optimised init from non-dict Mapping objects in from_records and frame/series constructors
#22638
ritchie46
merged 2 commits into
pola-rs:main
from
alexander-beedie:init-from-non-dict-mapping-objs
May 12, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collaborator
Author
|
Update: done... |
39d105e to
d834318
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22638 +/- ##
==========================================
+ Coverage 80.98% 80.99% +0.01%
==========================================
Files 1661 1661
Lines 234869 234937 +68
Branches 2773 2774 +1
==========================================
+ Hits 190198 190291 +93
+ Misses 44004 43978 -26
- Partials 667 668 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3e6a202 to
755f03b
Compare
…ecords` and frame/series constructors
from_records and frame/series constructorsMapping objects in from_records and frame/series constructors
755f03b to
db27f40
Compare
db27f40 to
2e01701
Compare
ritchie46
approved these changes
May 12, 2025
11 tasks
2 tasks
dangotbanned
added a commit
to dangotbanned/polars
that referenced
this pull request
Sep 23, 2025
Closes pola-rs#24583 Downstream in `narwhals`, we discovered the typing wasn't updated alongside the runtime support added in `1.30.0` ### Related - pola-rs#22638 - pola-rs#19322 - narwhals-dev/narwhals#3148 (comment) - narwhals-dev/narwhals#3148 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or an improvement of an existing feature
performance
Performance issues or improvements
python
Related to Python Polars
rust
Related to Rust Polars
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a path for
from_records(and DataFrame/Series construction) that can handle conversion fromPyMappingin the Rust/pyO3 layer (currently we only handlePyDict).This opens up efficient init from other useful Python record types that look like dicts to the caller (and support the
Mappingprotocol), but that we couldn't load as such (SQLAlchemyRowMapping, for example).Also:
Fixes two long-standing errors with
from_records, adding test coverage for both -Nonevalue.Nonevalue was present after the first record:TypeError: 'NoneType' object cannot be converted to 'PyDict'And:
Optimises
PyDictvalue lookup (by precomputing the keys asPyStringso we don't create them in the row-building loop).Example
Timings 🕐
(Tested with local
make build-dist-releasebinary).Having native conversion allows us to ingest
Mappingdata 2x faster than having the user convert it todictthemselves. We retain the separatedictfast-path, which remains optimal.