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

separate Input trait 'a and 'py lifetimes #1227

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Conversation

davidhewitt
Copy link
Contributor

Change Summary

This is in advance of supporting https://github.com/pydantic/jiter/pull/63/files

The main complication which I face there is that the Input<'data> lifetime is a bit mixed up in what lifetime should be 'py for the Python interpreter and which should be 'a for the data borrowed from the Input. When we start throwing the cow lifetime into the mix (which is equivalent to 'a) things get really mixed up if we don't try to untangle concepts first.

This PR separates out those two concepts more cleanly. In general this means that code which previously took &'data impl Input<'data> now just takes &impl Input<'py> in most places.

I looked at more extreme alternatives like removing the 'py lifetime from the trait entirely. That might still be still on the cards, but it would require some more extensive refactoring and this would be a precursor anyway.

Related issue number

N/A

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Copy link

codspeed-hq bot commented Mar 14, 2024

CodSpeed Performance Report

Merging #1227 will not alter performance

Comparing dh/input-lifetime (10fc43c) with main (9efbc16)

Summary

✅ 148 untouched benchmarks

@davidhewitt davidhewitt merged commit 8db3a6f into main Mar 14, 2024
28 checks passed
@davidhewitt davidhewitt deleted the dh/input-lifetime branch March 14, 2024 20:46
where
Self: 'a;
fn borrow_input(&self) -> &Self::Input<'_>;
pub trait BorrowInput<'py> {
Copy link
Member

Choose a reason for hiding this comment

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

looks like the docstring above this might be out of date.

@davidhewitt davidhewitt mentioned this pull request Mar 18, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants