René's URL Explorer Experiment


Title: gh-153569: Add tokenizer source and cursor primitives by pablogsal · Pull Request #153587 · python/cpython · GitHub

Open Graph Title: gh-153569: Add tokenizer source and cursor primitives by pablogsal · Pull Request #153587 · python/cpython

X Title: gh-153569: Add tokenizer source and cursor primitives by pablogsal · Pull Request #153587 · python/cpython

Description: This adds the decoded source store, offset spans, and an offset-only cursor as the foundation for moving tokenizer state away from buffer pointers. For example: // Own decoded bytes by line. _PyTok_SourceText source; _PyTok_SourceInit(&source); static const char text[] = "answer = 42\n"; _PyTok_Off line_start = _PyTok_SourceAppendLine( &source, text, sizeof(text) - 1, 0); assert(line_start >= 0); // Navigate by source offset. _PyTok_Cursor cursor; _PyTok_CursorInit(&cursor, &source); assert(_PyTok_CursorSetOffset(&cursor, line_start) == 0); _PyTok_Off name_start = cursor.pos; while (_PyTok_CursorPeek(&cursor, 0) != ' ') { assert(_PyTok_CursorAdvance(&cursor) != EOF); } // Keep token text as a half-open span. _PyTok_Span name = _PyTok_SpanFromBounds(name_start, cursor.pos); // Borrow a temporary view. Py_ssize_t name_len; const char *name_text = _PyTok_SourceSpanView(&source, name, &name_len); assert(name_text != NULL); assert(name_len == 6 && memcmp(name_text, "answer", name_len) == 0); _PyTok_SourceClear(&source); This PR only adds these primitives and their direct tests. It does not migrate the existing readers, lexer and f-string state, pegen, or _tokenize; those changes can be built on this API in separate PRs. Issue: gh-153569

Open Graph Description: This adds the decoded source store, offset spans, and an offset-only cursor as the foundation for moving tokenizer state away from buffer pointers. For example: // Own decoded bytes by line. _PyTok...

X Description: This adds the decoded source store, offset spans, and an offset-only cursor as the foundation for moving tokenizer state away from buffer pointers. For example: // Own decoded bytes by line. _PyTok...

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

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:0653b531-9049-41f0-e360-0fd084fb01f2
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBC2E:2E9831:1A5DFFE:22D48AE:6B021845
html-safe-nonce6ff8128125c03f010279a42707ed3cd856bc07b74afc2d56b3dbf3982f920012
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzJFOjJFOTgzMToxQTVERkZFOjIyRDQ4QUU6NkIwMjE4NDUiLCJ2aXNpdG9yX2lkIjoiMzI2NDExMDIyMzAwNzQ3ODQ1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac3b62948595ae6abf9c0827be071d4715e515d36224693f14b65e77509e0e3d21
hovercard-subject-tagpull_request:4036560946
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/153587/files
twitter:imagehttps://avatars.githubusercontent.com/u/11718525?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/11718525?s=400&v=4
og:image:altThis adds the decoded source store, offset spans, and an offset-only cursor as the foundation for moving tokenizer state away from buffer pointers. For example: // Own decoded bytes by line. _PyTok...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
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
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/153587/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F153587%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F153587%2Ffiles
Sign uphttps://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/153587/files
Reloadhttps://github.com/python/cpython/pull/153587/files
Reloadhttps://github.com/python/cpython/pull/153587/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
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
pablogsalhttps://github.com/pablogsal
python:mainhttps://github.com/python/cpython/tree/main
pablogsal:gh-153569-tokenizer-offset-apihttps://github.com/pablogsal/cpython/tree/gh-153569-tokenizer-offset-api
Conversation 3 https://github.com/python/cpython/pull/153587
Commits 3 https://github.com/python/cpython/pull/153587/commits
Checks 68 https://github.com/python/cpython/pull/153587/checks
Files changed https://github.com/python/cpython/pull/153587/files
Please reload this pagehttps://github.com/python/cpython/pull/153587/files
gh-153569: Add tokenizer source and cursor primitives https://github.com/python/cpython/pull/153587/files#top
Show all changes 3 commits https://github.com/python/cpython/pull/153587/files
697e7dd gh-153569: Add tokenizer source and cursor primitives pablogsal Jul 11, 2026 https://github.com/python/cpython/pull/153587/commits/697e7dd9882062ea0778eea04a1cc5cd8588f02b
100072c fixup! gh-153569: Add tokenizer source and cursor primitives pablogsal Jul 18, 2026 https://github.com/python/cpython/pull/153587/commits/100072cdf64821afd159058d88e7ddce60268518
4b0454f fixup! gh-153569: Add tokenizer source and cursor primitives pablogsal Jul 18, 2026 https://github.com/python/cpython/pull/153587/commits/4b0454f54481c76371da6057600a95714f17fe1f
Clear filters https://github.com/python/cpython/pull/153587/files
Please reload this pagehttps://github.com/python/cpython/pull/153587/files
Please reload this pagehttps://github.com/python/cpython/pull/153587/files
test_tokenizer.py https://github.com/python/cpython/pull/153587/files#diff-16b4a247c227d32e31db7b6b107e9236edad213c710cb5b31584c846e93a533d
Makefile.pre.in https://github.com/python/cpython/pull/153587/files#diff-1f0a8db227d22005511b0d90f5339b97db345917b863954b3b3ccb9ec308767c
Setup.stdlib.in https://github.com/python/cpython/pull/153587/files#diff-93b54a98829ea89eaf6335c02f546511f7780d865131407436b10a401ecd375c
_testinternalcapi.c https://github.com/python/cpython/pull/153587/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
parts.h https://github.com/python/cpython/pull/153587/files#diff-41dbad38bccbb3dcd8994e2fe0e2673cab29faefc2912d1c02340e211ff8673f
tokenizer.c https://github.com/python/cpython/pull/153587/files#diff-bf867c315e7bf23f02713dfa30288b5352e1b1cc050dfebb334287359d33d963
_testinternalcapi.vcxproj https://github.com/python/cpython/pull/153587/files#diff-08566dae0ca25227bd1cb8ccdf68f73345c4a4cfa5dedf19315359a4eef6c710
_testinternalcapi.vcxproj.filters https://github.com/python/cpython/pull/153587/files#diff-4fa7325f4c1045bd2dedb7c74bfcba90496a7e3d14083038fc1a6935ac6e8a50
pythoncore.vcxproj https://github.com/python/cpython/pull/153587/files#diff-4295039788386c2986b811f2a6b59cf088be59822b24b4f1243c9e9b184f65fb
pythoncore.vcxproj.filters https://github.com/python/cpython/pull/153587/files#diff-9e715828befc9c50c8b483b06d4923cda0db44f57d0c20e6a6d428ba60bfa0c5
cursor.c https://github.com/python/cpython/pull/153587/files#diff-612535281447d780b732c38843952f91678c5d75d8396e55445dc375319d3813
cursor.h https://github.com/python/cpython/pull/153587/files#diff-f63563ab928ae9883992ec0dddbd66eab2ffd2abf172a22c91d754f7ac649f8c
source.c https://github.com/python/cpython/pull/153587/files#diff-d091331acd32f48897fc1503341091ee6066cbe2208017651deef042b32273da
source.h https://github.com/python/cpython/pull/153587/files#diff-033fac2d1c68ebec297cd0aaf7ee48c836b7ebab03362fcecc53cedcdac043d1
Lib/test/test_capi/test_tokenizer.pyhttps://github.com/python/cpython/pull/153587/files#diff-16b4a247c227d32e31db7b6b107e9236edad213c710cb5b31584c846e93a533d
View file https://github.com/pablogsal/cpython/blob/4b0454f54481c76371da6057600a95714f17fe1f/Lib/test/test_capi/test_tokenizer.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/153587/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L85
Makefile.pre.inhttps://github.com/python/cpython/pull/153587/files#diff-1f0a8db227d22005511b0d90f5339b97db345917b863954b3b3ccb9ec308767c
View file https://github.com/pablogsal/cpython/blob/4b0454f54481c76371da6057600a95714f17fe1f/Makefile.pre.in
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/153587/{{ revealButtonHref }}
https://github.com/python/cpython/pull/153587/files#diff-1f0a8db227d22005511b0d90f5339b97db345917b863954b3b3ccb9ec308767c
https://github.com/python/cpython/pull/153587/files#diff-1f0a8db227d22005511b0d90f5339b97db345917b863954b3b3ccb9ec308767c
https://github.com/python/cpython/pull/153587/files#diff-1f0a8db227d22005511b0d90f5339b97db345917b863954b3b3ccb9ec308767c
https://github.com/python/cpython/pull/153587/files#diff-1f0a8db227d22005511b0d90f5339b97db345917b863954b3b3ccb9ec308767c
https://github.com/python/cpython/pull/153587/files#diff-1f0a8db227d22005511b0d90f5339b97db345917b863954b3b3ccb9ec308767c
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L87
Modules/Setup.stdlib.inhttps://github.com/python/cpython/pull/153587/files#diff-93b54a98829ea89eaf6335c02f546511f7780d865131407436b10a401ecd375c
View file https://github.com/pablogsal/cpython/blob/4b0454f54481c76371da6057600a95714f17fe1f/Modules/Setup.stdlib.in
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/153587/{{ revealButtonHref }}
https://github.com/python/cpython/pull/153587/files#diff-93b54a98829ea89eaf6335c02f546511f7780d865131407436b10a401ecd375c
https://github.com/python/cpython/pull/153587/files#diff-93b54a98829ea89eaf6335c02f546511f7780d865131407436b10a401ecd375c
Modules/_testinternalcapi.chttps://github.com/python/cpython/pull/153587/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
View file https://github.com/pablogsal/cpython/blob/4b0454f54481c76371da6057600a95714f17fe1f/Modules/_testinternalcapi.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/153587/{{ revealButtonHref }}
https://github.com/python/cpython/pull/153587/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
https://github.com/python/cpython/pull/153587/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
Modules/_testinternalcapi/parts.hhttps://github.com/python/cpython/pull/153587/files#diff-41dbad38bccbb3dcd8994e2fe0e2673cab29faefc2912d1c02340e211ff8673f
View file https://github.com/pablogsal/cpython/blob/4b0454f54481c76371da6057600a95714f17fe1f/Modules/_testinternalcapi/parts.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/153587/{{ revealButtonHref }}
https://github.com/python/cpython/pull/153587/files#diff-41dbad38bccbb3dcd8994e2fe0e2673cab29faefc2912d1c02340e211ff8673f
https://github.com/python/cpython/pull/153587/files#diff-41dbad38bccbb3dcd8994e2fe0e2673cab29faefc2912d1c02340e211ff8673f
Modules/_testinternalcapi/tokenizer.chttps://github.com/python/cpython/pull/153587/files#diff-bf867c315e7bf23f02713dfa30288b5352e1b1cc050dfebb334287359d33d963
View file https://github.com/pablogsal/cpython/blob/4b0454f54481c76371da6057600a95714f17fe1f/Modules/_testinternalcapi/tokenizer.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/153587/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L190
PCbuild/_testinternalcapi.vcxprojhttps://github.com/python/cpython/pull/153587/files#diff-08566dae0ca25227bd1cb8ccdf68f73345c4a4cfa5dedf19315359a4eef6c710
View file https://github.com/pablogsal/cpython/blob/4b0454f54481c76371da6057600a95714f17fe1f/PCbuild/_testinternalcapi.vcxproj
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/153587/{{ revealButtonHref }}
https://github.com/python/cpython/pull/153587/files#diff-08566dae0ca25227bd1cb8ccdf68f73345c4a4cfa5dedf19315359a4eef6c710
https://github.com/python/cpython/pull/153587/files#diff-08566dae0ca25227bd1cb8ccdf68f73345c4a4cfa5dedf19315359a4eef6c710
Please reload this pagehttps://github.com/python/cpython/pull/153587/files
Please reload this pagehttps://github.com/python/cpython/pull/153587/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.