FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-102491: Remove IronPython version check in sys_version by eendebakpt · Pull Request #102492 · python/cpython · GitHub

Repository navigation

gh-102491: Remove IronPython version check in sys_version - #102492

Merged
hauntsaninja merged 8 commits into
python:mainfrom
eendebakpt:remove_ironpython_python2
Mar 19, 2023
Merged

hauntsaninja merged 8 commits into
python:mainfrom
eendebakpt:remove_ironpython_python2

Conversation

eendebakpt commented Mar 7, 2023 •
edited
Loading

Copy link
Copy Markdown
Contributor

The platform module contains various version checks for systems such as cpython and ironpython. The file also contains a specfic case for ironpython which can be removed (see IronLanguages/ironpython3#1667)

Removing the check improves the import speed as it avoids the compilation of a two regular expressions.

%timeit _ironpython26_sys_version_parser = re.compile(r'([\d.]+)\s*'   r'\(IronPython\s*'    r'[\d.]+\s*'    r'\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)' )
383 ns ± 1.66 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

Note: most of the compiled regular expressions in platform.py can be moved into the methods using them, as most results are cached. This would reduce the importtime for platform even further:

Main: The speed of "import platform" is: 8.231517 +- 0.499458 [ms]
Regular expressions adapted: The speed of "import platform" is: 7.182120 +- 0.726896 [ms]

hauntsaninja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks, this looks good. Would you mind adding the news entry?

hauntsaninja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hm, not an issue with this PR, but I was curious what IronPython is doing. It looks like their platform.py has https://github.com/IronLanguages/ironpython3/blob/f41afc44534786721b89e1efb8e50c4232ee1224/Src/StdLib/Lib/platform.py#L1141 and https://github.com/IronLanguages/ironpython3/blob/f41afc44534786721b89e1efb8e50c4232ee1224/Src/StdLib/Lib/platform.py#L1187

Weirdly, IronPython's docs indicates that its sys.version would not match the regex we have or the regex they have in their platform.py.

Copy link
Copy Markdown
Contributor Author

Hm, not an issue with this PR, but I was curious what IronPython is doing. It looks like their platform.py has https://github.com/IronLanguages/ironpython3/blob/f41afc44534786721b89e1efb8e50c4232ee1224/Src/StdLib/Lib/platform.py#L1141 and https://github.com/IronLanguages/ironpython3/blob/f41afc44534786721b89e1efb8e50c4232ee1224/Src/StdLib/Lib/platform.py#L1187

Weirdly, IronPython's docs indicates that its sys.version would not match the regex we have or the regex they have in their platform.py.

@hauntsaninja Good point. I created an issue IronLanguages/ironpython3#1667. Based on the decision there, can you (as core dev) make a decision on the other ironpython regular expression.

eendebakpt changed the title gh-102491: remove ironpython python 2.x version check gh-102491: Remove IronPython version check in sys_version Mar 12, 2023
eendebakpt requested a review from hauntsaninja March 12, 2023 21:53

hauntsaninja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL