-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
COMPAT: Remove use of private re attribute #20553
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
Conversation
This is a bit slower. 3.6 In [3]: t1 = typing.re.Pattern
In [4]: t2 = type(re.compile(''))
In [5]: %timeit isinstance('', t1)
424 ns ± 8.76 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
In [6]: %timeit isinstance('', t2)
99.5 ns ± 1.58 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) 3.7 In [1]: import re
In [2]: import typing
In [3]: t1 = typing.re.Pattern
In [4]: t2 = type(re.compile(''))
In [5]: %timeit isinstance('', t1)
741 ns ± 9.73 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
In [6]: %timeit isinstance('', t2)
105 ns ± 1.62 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) So just use I think the timings are small enough, that I'd rather just use |
pandas/compat/__init__.py
Outdated
@@ -423,6 +423,12 @@ def raise_with_traceback(exc, traceback=Ellipsis): | |||
parse_date = _date_parser.parse | |||
|
|||
|
|||
if PY36: |
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.
can you add a comment / pep ref here
Codecov Report
@@ Coverage Diff @@
## master #20553 +/- ##
==========================================
+ Coverage 91.81% 91.83% +0.02%
==========================================
Files 152 152
Lines 49259 49264 +5
==========================================
+ Hits 45229 45244 +15
+ Misses 4030 4020 -10
Continue to review full report at Codecov.
|
@@ -423,6 +423,7 @@ def raise_with_traceback(exc, traceback=Ellipsis): | |||
parse_date = _date_parser.parse | |||
|
|||
|
|||
# In Python 3.7, the private re._pattern_type is removed. |
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.
shouldn't this be for PY37 then?
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.
typing.re
was added in Python 3.5. I assume we want to use the officially documented way to check for regex pattern types.
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.
sorry i only read the top comment. ok then.
lgtm. |
thanks! |
Closes #20551