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: Use direct path for time/timedelta literals #18223

Merged
merged 6 commits into from
Aug 19, 2024

Conversation

mcrumiller
Copy link
Contributor

Slight followup to #16018, allows direct construction of literals from datetime.time and datetime.timedelta objects.

@github-actions github-actions bot added performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars labels Aug 15, 2024
@mcrumiller
Copy link
Contributor Author

Failures are deltalake, unrelated to PR.

Copy link
Collaborator

@alexander-beedie alexander-beedie left a comment

Choose a reason for hiding this comment

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

I don't think the added tests actually cover the change 🤔 The existing Python pl.lit already handles both types, your update enhances the lower-level Rust fn lit (definitely worthwhile), but the tests look to be validating the existing functionality?

@mcrumiller
Copy link
Contributor Author

I don't think the added tests actually cover the change 🤔 The existing Python pl.lit already handles both types, your update enhances the lower-level Rust fn lit (definitely worthwhile), but the tests look to be validating the existing functionality?

lit.py was updated to pass the time and timedelta values directly to plr.lit, as opposed to the prior implementation that first converted their values to int. Does this not test the new functionality?

Copy link

codspeed-hq bot commented Aug 16, 2024

CodSpeed Performance Report

Merging #18223 will not alter performance

Comparing mcrumiller:literal-time (e622fd9) with main (1dc2533)

Summary

✅ 37 untouched benchmarks

Copy link

codecov bot commented Aug 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.22%. Comparing base (7654387) to head (e622fd9).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18223      +/-   ##
==========================================
- Coverage   80.30%   80.22%   -0.08%     
==========================================
  Files        1499     1500       +1     
  Lines      198744   198886     +142     
  Branches     2837     2837              
==========================================
- Hits       159604   159561      -43     
- Misses      38613    38798     +185     
  Partials      527      527              

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

@mcrumiller
Copy link
Contributor Author

mcrumiller commented Aug 16, 2024

My failed test is an apparently rare hypothesis case; I'll open an issue, maybe @MarcoGorelli can take a look.

Update: #18239.

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.

Thanks. I think it is cleaner than our previous cast solution. Can you rebase, as we just moved the whole logic to a new crate, I doubt we can merge as is.

And there is a rogue print.

) {
println!("here");
Copy link
Member

Choose a reason for hiding this comment

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

rogue print

@mcrumiller
Copy link
Contributor Author

@ritchie46 I had rebased earlier. Just removed the print. Can you or @alexander-beedie verify that his concern is actually covered here?

time(hour=23, minute=59, second=59, microsecond=999999),
],
)
def test_literal_from_time(value: time) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

These tests can be better. You should call explain(optimized=False) and check there is no cast in there.

@ritchie46
Copy link
Member

@ritchie46 I had rebased earlier. Just removed the print. Can you or @alexander-beedie verify that his concern is actually covered here?

See comment. The test would already pass without this PR. My suggestion would be better.

@mcrumiller
Copy link
Contributor Author

@ritchie46 I added the check, but the test still passes on the main branch anyway. Any further suggestions? I think the fact that the test still works despite the PR should be enough, no?

@ritchie46
Copy link
Member

Yes, the IR conversion optimizes it away. So the test is not super useful. Let's remove the test and then merge. :P

@mcrumiller
Copy link
Contributor Author

@ritchie46 removed the cast check. The lit tests are still worthwhile to have to ensure we can still create literals correctly.

@ritchie46 ritchie46 merged commit 5d874b1 into pola-rs:main Aug 19, 2024
27 checks passed
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 rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants