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

feat(python): 30x speedup initialising Series from python range object #5397

Merged
merged 2 commits into from
Nov 2, 2022
Merged

feat(python): 30x speedup initialising Series from python range object #5397

merged 2 commits into from
Nov 2, 2022

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Nov 2, 2022

Took a quick look at #5395 (on my lunch break, hah :) and spotted an optimisation opportunity; can automatically substitute python range for polars' arange expression.

import polars as pl
s = pl.Series( range(1_000_000_000) )

Before: 31.87s
After: 1.045s

FYI: looks like pandas was already doing a similar optimisation; we were much slower, and now we're ~40% faster (pandas timing for Series init with the same range object: 1.47s).

Can look at the actual issue itself later this evening.

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Nov 2, 2022
Copy link
Member

@ritchie46 ritchie46 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So simple. :)

py-polars/polars/internals/lazy_functions.py Show resolved Hide resolved
py-polars/polars/internals/lazy_functions.py Show resolved Hide resolved
py-polars/polars/internals/series/series.py Show resolved Hide resolved
@ritchie46 ritchie46 merged commit ad678ca into pola-rs:master Nov 2, 2022
@alexander-beedie alexander-beedie deleted the fast-path-range-init branch November 2, 2022 18:31
zundertj pushed a commit to zundertj/polars that referenced this pull request Jan 7, 2023
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 python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants