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

perf(python): Construct Series for bytes/binary data 10x faster when dtype not explicitly set #20157

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Dec 5, 2024

Can still detect/use the fast-path binary constructor, rather than the generic object constructor, even when the dtype was not explicitly set as pl.Binary.

Not a bad return on a one-line update ;)

Example

from codetiming import Timer
import polars as pl

binary_data = [str(n).encode("utf8") for n in range(50_000_000)]

with Timer():
    s = pl.Series(binary_data)

Timings

Before: 5.6219 secs  (new_object)
 After: 0.5609 secs  (new_binary) 🚀

@alexander-beedie alexander-beedie changed the title perf(python): 10x faster Series construction for bytes/binary data when dtype not explicitly set perf(python): Construct Series for bytes/binary data 10x faster when dtype not explicitly set Dec 5, 2024
@github-actions github-actions bot added performance Performance issues or improvements python Related to Python Polars and removed title needs formatting labels Dec 5, 2024
@alexander-beedie alexander-beedie force-pushed the faster-binary-series-init branch from bf69c30 to 5cc49b9 Compare December 5, 2024 06:55
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.58%. Comparing base (3fb10e8) to head (5cc49b9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20157      +/-   ##
==========================================
- Coverage   79.58%   79.58%   -0.01%     
==========================================
  Files        1563     1563              
  Lines      217417   217417              
  Branches     2472     2472              
==========================================
- Hits       173023   173021       -2     
- Misses      43826    43828       +2     
  Partials      568      568              

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

@ritchie46 ritchie46 merged commit 6153f37 into pola-rs:main Dec 5, 2024
14 checks passed
@alexander-beedie alexander-beedie deleted the faster-binary-series-init branch December 5, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance issues or improvements python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants