Title: Deprecate the unused `tokenize._compile` function · Issue #143009 · python/cpython · GitHub
Open Graph Title: Deprecate the unused `tokenize._compile` function · Issue #143009 · python/cpython
X Title: Deprecate the unused `tokenize._compile` function · Issue #143009 · python/cpython
Description: Feature or enhancement Proposal: Remove the unused tokenize._compile function. EDIT: Deprecate the unused tokenize._compile function. It very much looks like the internal tokenize._compile function hasn't been needed since GH-104323 when...
Open Graph Description: Feature or enhancement Proposal: Remove the unused tokenize._compile function. EDIT: Deprecate the unused tokenize._compile function. It very much looks like the internal tokenize._compile function...
X Description: Feature or enhancement Proposal: Remove the unused tokenize._compile function. EDIT: Deprecate the unused tokenize._compile function. It very much looks like the internal tokenize._compile function...
Opengraph URL: https://github.com/python/cpython/issues/143009
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Deprecate the unused `tokenize._compile` function","articleBody":"# Feature or enhancement\n\n### Proposal:\n\n~~Remove the unused `tokenize._compile` function.~~ EDIT: Deprecate the unused `tokenize._compile` function.\n\nIt very much looks like the internal `tokenize._compile` function hasn't been needed since GH-104323 when it was initially removed, but it was mechanically brought back to `tokenize` in GH-104722 to fix GH-104719.\n\nFrom a quick search, it seems that, prior to GH-104323, `tokenize._compile` was only used internally in `tokenize._tokenize`.\n\nMost of the fairly fresh [code I skimmed through on GitHub](https://github.com/search?q=tokenize._compile\u0026type=code) operating on `tokenize._compile` properly checks if Python is version \u003c3.10 / `tokenize._compile` exists.\n\nExcept [`CheetahTemplate3`](https://github.com/CheetahTemplate3/cheetah3/blob/071b8a0faf5eb7728d771b5dd47d0806316f4bee/Cheetah/Parser.py#L24), so removing `tokenize._compile` immediately could break them -- we need to deprecate first.\n\nIn terms of benefits of removing this at some point: it wouldn't necessarily improve the import time of `tokenize` as long as `re` still imports `functools` to cache template compilation. Therefore, removing `tokenize._compile` in the future is just a small cleanup that yields no other benefits than smaller, less bloated code.\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_","author":{"url":"https://github.com/johnslavik","@type":"Person","name":"johnslavik"},"datePublished":"2025-12-20T05:01:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/143009/cpython/issues/143009"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1472fb84-d0d0-9894-1810-c724ab9bcd15 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A28C:B7E00:56F924:7069FC:696B483F |
| html-safe-nonce | d6195715327ca8e0f8b4fdc56b19e24905325fb86610dc339555ea44903b9ec0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjhDOkI3RTAwOjU2RjkyNDo3MDY5RkM6Njk2QjQ4M0YiLCJ2aXNpdG9yX2lkIjoiODY5MTg5MDc4NjU5Mzg4NDIyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 39cc66dd7ebc887110a82ce90b1936fc13e2cb95b3571ed656d014629ae78cd4 |
| hovercard-subject-tag | issue:3749558488 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/143009/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e2371095e352f9aef561f0b27cf2c89d2736b2be96d46d6dc29e99fc6cdd8cd6/python/cpython/issues/143009 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e2371095e352f9aef561f0b27cf2c89d2736b2be96d46d6dc29e99fc6cdd8cd6/python/cpython/issues/143009 |
| og:image:alt | Feature or enhancement Proposal: Remove the unused tokenize._compile function. EDIT: Deprecate the unused tokenize._compile function. It very much looks like the internal tokenize._compile function... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | johnslavik |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width