René's URL Explorer Experiment


Title: gh-130167: Improve speed of `ftplib.parse150` by replacing `re` by donbarbos · Pull Request #130243 · python/cpython · GitHub

Open Graph Title: gh-130167: Improve speed of `ftplib.parse150` by replacing `re` by donbarbos · Pull Request #130243 · python/cpython

X Title: gh-130167: Improve speed of `ftplib.parse150` by replacing `re` by donbarbos · Pull Request #130243 · python/cpython

Description: I also suggest adding tests for this function because they are missing in the Lib/test/test_ftplib.py file. I wrote tests (would be in next comment) and benchmarks (results here) parse150_bench.py: from Lib.ftplib import error_reply import timeit # Regex version _150_re = None def parse150_re(resp): if resp[:3] != "150": raise error_reply(resp) global _150_re if _150_re is None: import re _150_re = re.compile(r"150 .* \((\d+) bytes\)", re.IGNORECASE | re.ASCII) m = _150_re.match(resp) if not m: return None return int(m.group(1)) # No regex version def parse150(resp): if not resp.startswith("150"): raise error_reply(resp) start = resp.find("(") end = resp.find(" bytes)") if start == -1 or end == -1 or start >= end: return None try: return int(resp[start + 1 : end]) except ValueError: return None test_cases = [ "150 Opening BINARY mode data connection (4096 bytes)", "150 Transfer starting (32768 bytes)", "150 Data connection accepted (131072 bytes)", "150 Some random message without bytes", "150 Large file transfer (987654321 bytes)", "150 Small file (1 bytes)", "150 Transfer starting (99999999 bytes)", "150 Weird case (42 bytes) with extra text", ] for case in test_cases: regex_time = timeit.timeit(lambda: parse150_re(case), number=1_000_000) no_regex_time = timeit.timeit(lambda: parse150(case), number=1_000_000) print(f"Test case: {case}") print(f" Regex version: {regex_time:.6f} sec") print(f" No regex version: {no_regex_time:.6f} sec") Results for different cases (from x1.82 to x1.92 as fast): $ ./python -B parse150_bench.py Test case: 150 Opening BINARY mode data connection (4096 bytes) Regex version: 1.147499 sec No regex version: 0.630863 sec Test case: 150 Transfer starting (32768 bytes) Regex version: 1.113087 sec No regex version: 0.610494 sec Test case: 150 Data connection accepted (131072 bytes) Regex version: 1.140198 sec No regex version: 0.616784 sec Test case: 150 Some random message without bytes Regex version: 0.643958 sec No regex version: 0.302508 sec Test case: 150 Large file transfer (987654321 bytes) Regex version: 1.160474 sec No regex version: 0.605776 sec Test case: 150 Small file (1 bytes) Regex version: 1.005945 sec No regex version: 0.522877 sec Test case: 150 Transfer starting (99999999 bytes) Regex version: 1.147927 sec No regex version: 0.616777 sec Test case: 150 Weird case (42 bytes) with extra text Regex version: 1.140925 sec No regex version: 0.592486 sec Issue: gh-130167

Open Graph Description: I also suggest adding tests for this function because they are missing in the Lib/test/test_ftplib.py file. I wrote tests (would be in next comment) and benchmarks (results here) parse150_bench.py:...

X Description: I also suggest adding tests for this function because they are missing in the Lib/test/test_ftplib.py file. I wrote tests (would be in next comment) and benchmarks (results here) parse150_bench.py:...

Opengraph URL: https://github.com/python/cpython/pull/130243

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:bb514d24-9339-8afd-a7eb-e0921bc1735f
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD464:3A35C6:1C7C405:2580B30:696AF9F4
html-safe-noncef1baa64b75f27a3f1d43616ed0ec677c83e5005422272356e54176b05eb4e125
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDY0OjNBMzVDNjoxQzdDNDA1OjI1ODBCMzA6Njk2QUY5RjQiLCJ2aXNpdG9yX2lkIjoiNjUxMzY1OTcxNjgyOTkwMzM0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2b013fa6e8a0899e3841b99b1bbdc8e857c27dda23d53fdfff1e71cdcd3c7d23
hovercard-subject-tagpull_request:2340839963
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/130243/files
twitter:imagehttps://avatars.githubusercontent.com/u/47272787?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/47272787?s=400&v=4
og:image:altI also suggest adding tests for this function because they are missing in the Lib/test/test_ftplib.py file. I wrote tests (would be in next comment) and benchmarks (results here) parse150_bench.py:...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release82560a55c6b2054555076f46e683151ee28a19bc
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/130243/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F130243%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F130243%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/130243/files
Reloadhttps://github.com/python/cpython/pull/130243/files
Reloadhttps://github.com/python/cpython/pull/130243/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/130243/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/130243/files
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
donbarboshttps://github.com/donbarbos
python:mainhttps://github.com/python/cpython/tree/main
donbarbos:improve-parse150-speedhttps://github.com/donbarbos/cpython/tree/improve-parse150-speed
Conversation 5 https://github.com/python/cpython/pull/130243
Commits 5 https://github.com/python/cpython/pull/130243/commits
Checks 35 https://github.com/python/cpython/pull/130243/checks
Files changed https://github.com/python/cpython/pull/130243/files
Please reload this pagehttps://github.com/python/cpython/pull/130243/files
gh-130167: Improve speed of ftplib.parse150 by replacing re https://github.com/python/cpython/pull/130243/files#top
Show all changes 5 commits https://github.com/python/cpython/pull/130243/files
4055dbe Improve speed of ftplib.parse150 by replacing re donbarbos Feb 18, 2025 https://github.com/python/cpython/pull/130243/commits/4055dbed316e0a10b71ba6a8876d16fde8a0b98b
043de73 Add blurb NEWS.d entry donbarbos Feb 18, 2025 https://github.com/python/cpython/pull/130243/commits/043de739b6c67a01d2152ad8e94484ec7f31e6db
8ad9c5e Correct blurb entry file donbarbos Feb 18, 2025 https://github.com/python/cpython/pull/130243/commits/8ad9c5e556b1bd68e470e182cecc104dc518e003
e5dd027 Ignore case while finding donbarbos Feb 18, 2025 https://github.com/python/cpython/pull/130243/commits/e5dd0276f9086e28344328505937575408e9d3b9
db0a29a Update NEWS.d entry markup donbarbos Feb 18, 2025 https://github.com/python/cpython/pull/130243/commits/db0a29a00a4a0cc6bf101a17f4b38fc96ffeab28
Clear filters https://github.com/python/cpython/pull/130243/files
Please reload this pagehttps://github.com/python/cpython/pull/130243/files
Please reload this pagehttps://github.com/python/cpython/pull/130243/files
ftplib.py https://github.com/python/cpython/pull/130243/files#diff-14623a6f9f5b7c4acd8d258609b07bbba40ca65a9d3ab4d260b10e5540ac1ab0
2025-02-18-05-00-24.gh-issue-130167.e0MXUp.rst https://github.com/python/cpython/pull/130243/files#diff-6b1dc98fff5d69aab327ca80fa883df664b53a9e0215f3435cf602a41d58c462
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L459
Lib/ftplib.pyhttps://github.com/python/cpython/pull/130243/files#diff-14623a6f9f5b7c4acd8d258609b07bbba40ca65a9d3ab4d260b10e5540ac1ab0
View file https://github.com/donbarbos/cpython/blob/db0a29a00a4a0cc6bf101a17f4b38fc96ffeab28/Lib/ftplib.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/130243/{{ revealButtonHref }}
https://github.com/python/cpython/pull/130243/files#diff-14623a6f9f5b7c4acd8d258609b07bbba40ca65a9d3ab4d260b10e5540ac1ab0
https://github.com/python/cpython/pull/130243/files#diff-14623a6f9f5b7c4acd8d258609b07bbba40ca65a9d3ab4d260b10e5540ac1ab0
Misc/NEWS.d/next/Library/2025-02-18-05-00-24.gh-issue-130167.e0MXUp.rsthttps://github.com/python/cpython/pull/130243/files#diff-6b1dc98fff5d69aab327ca80fa883df664b53a9e0215f3435cf602a41d58c462
View file https://github.com/donbarbos/cpython/blob/db0a29a00a4a0cc6bf101a17f4b38fc96ffeab28/Misc/NEWS.d/next/Library/2025-02-18-05-00-24.gh-issue-130167.e0MXUp.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/130243/{{ revealButtonHref }}
Please reload this pagehttps://github.com/python/cpython/pull/130243/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.