Skip to content

Conversation

@AndreaBozzo
Copy link
Contributor

@AndreaBozzo AndreaBozzo commented Dec 9, 2025

Noticed a TODO in the code asking for more efficient implementations , this PR tackles that by adding TrustedLen variants and removing the Result wrapper workarounds.

I did not plan on adding tests on this, but i can improve the coverage if maintainers want to

  • Add direct implementations instead of delegating through Result wrappers
  • Add TrustedLen variants for exact pre-allocation
  • Remove unnecessary indirection and .unwrap() calls

Test plan

  • cargo build -p polars-core --features object
  • cargo test -p polars-core --features object

@github-actions github-actions bot added A-dtype-object Area: object data type performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars labels Dec 9, 2025
@AndreaBozzo AndreaBozzo force-pushed the perf/optimize-objectarray-arrayfromiter branch from cb9330a to 30d8dbe Compare December 9, 2025 19:04
- Add direct implementations instead of delegating through `Result` wrappers
- Add `TrustedLen` variants (`arr_from_iter_trusted`, `try_arr_from_iter_trusted`)
  for both `&T` and `Option<&T>` to enable exact pre-allocation
- Remove unnecessary indirection and `.unwrap()` calls
- Remove TODO comment as the implementations are now efficient
@AndreaBozzo AndreaBozzo force-pushed the perf/optimize-objectarray-arrayfromiter branch from 30d8dbe to a62278e Compare December 9, 2025 19:07
@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 37.00000% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.66%. Comparing base (37cda80) to head (a0ceae7).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
.../polars-core/src/datatypes/static_array_collect.rs 37.00% 63 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25712      +/-   ##
==========================================
- Coverage   80.57%   79.66%   -0.92%     
==========================================
  Files        1764     1764              
  Lines      242704   242823     +119     
  Branches     3042     3044       +2     
==========================================
- Hits       195561   193445    -2116     
- Misses      46361    48596    +2235     
  Partials      782      782              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AndreaBozzo AndreaBozzo marked this pull request as ready for review December 9, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-dtype-object Area: object data type performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant