-
Notifications
You must be signed in to change notification settings - Fork 160
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
Introduce absolute cached property #1100
Conversation
We call is_absolute quite often internally and externally. Curently this requires re-parsing the netloc. To make the API more consistent and perform better, absolute is now preferred over is_absolute. is_absolute is retained for backwards compatibility.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1100 +/- ##
==========================================
+ Coverage 94.90% 94.91% +0.01%
==========================================
Files 30 30
Lines 4358 4367 +9
Branches 382 383 +1
==========================================
+ Hits 4136 4145 +9
Misses 196 196
Partials 26 26
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Getting closer to the point where |
@@ -1307,26 +1307,31 @@ def test_with_suffix_replace(): | |||
def test_is_absolute_for_relative_url(): | |||
url = URL("/path/to") | |||
assert not url.is_absolute() | |||
assert not url.absolute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdraco cached things are usually tested through their __wrapped__
attributes to prevent caching from influencing behavior in tests. Have you considered doing something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the URL object is immutable and the state is already predefined we shouldn’t have much risk of the cached value being calculated incorrectly.
Was there a specific case you are concerned about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, just got surprised seeing this and thought I'd mention it.
What do these changes do?
We call
is_absolute
quite often internally and externally. Currently this requires re-parsing thenetloc
. To make the API more consistent and perform better,absolute
is now preferred overis_absolute
.is_absolute
is retained for backwards compatibility.Are there changes in behavior for the user?
absolute
is now preferred overis_absolute
, however there are no plans to removeis_absolute
.Probably not the best representation of a microbenchmark since
raw_host
would previous be a cache miss most of the time and this change will perform much better either way:On previous version when
raw_host
is a cache miss