Title: `.pyc` files are larger than they need to be · Issue #99554 · python/cpython · GitHub
Open Graph Title: `.pyc` files are larger than they need to be · Issue #99554 · python/cpython
X Title: `.pyc` files are larger than they need to be · Issue #99554 · python/cpython
Description: Python 3.11 made .pyc files almost twice as large. There are two main reasons for this: PEP 659 made the bytecode stream ~3x as large as 3.10. PEP 657 made the location tables ~9x as large as 3.10. (Note that these effects compound each ...
Open Graph Description: Python 3.11 made .pyc files almost twice as large. There are two main reasons for this: PEP 659 made the bytecode stream ~3x as large as 3.10. PEP 657 made the location tables ~9x as large as 3.10....
X Description: Python 3.11 made .pyc files almost twice as large. There are two main reasons for this: PEP 659 made the bytecode stream ~3x as large as 3.10. PEP 657 made the location tables ~9x as large as 3.10....
Opengraph URL: https://github.com/python/cpython/issues/99554
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`.pyc` files are larger than they need to be","articleBody":"Python 3.11 made `.pyc` files almost twice as large. There are two main reasons for this:\r\n- [PEP 659](https://peps.python.org/pep-0659/) made the bytecode stream ~3x as large as 3.10.\r\n- [PEP 657](https://peps.python.org/pep-0657/) made the location tables ~9x as large as 3.10.\r\n\r\n(Note that these effects compound each other, since longer bytecode means more location entries.)\r\n\r\nHowever, there is low-hanging fruit for improving this situation in 3.12:\r\n- Bytecode can be compressed using a fairly simple scheme (one byte for instructions without an oparg, two bytes for instructions with an oparg, and zero bytes for `CACHE` entries). **This results in serialized bytecode that is ~66% smaller than 3.11.**\r\n- The location table format already has a mechanism for compressing multiple code units into a single entry. Currently it's only used for `EXTENDED_ARG`s and `CACHE`s corresponding to a single instruction, but with slight changes the compiler can use the same mechanism to share location table entries between adjacent instructions. This is a double-win, since it not only makes `.pyc` files smaller, but also shrinks the memory footprint of all code objects in the process. **Experiments show that this makes location tables ~33% smaller than 3.11.**\r\n\r\nWhen both of these optimizations are applied, `.pyc` files become ~33% smaller than 3.11. This is only ~33% larger than 3.10, despite all of the rich new debugging information present.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-99555\n* gh-99556\n* gh-100435\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/brandtbucher","@type":"Person","name":"brandtbucher"},"datePublished":"2022-11-17T00:15:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/99554/cpython/issues/99554"}
| 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:ca73570c-808c-9aa3-12b3-ddebed95b84a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7A2:22C818:1413160:1C87B92:69691A08 |
| html-safe-nonce | 787ebfd458043c28a0658b206309f0be7ab0bf5b31b57a3bb8e84072acc5e865 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0EyOjIyQzgxODoxNDEzMTYwOjFDODdCOTI6Njk2OTFBMDgiLCJ2aXNpdG9yX2lkIjoiMjA2MTMzMzIyMzM0Mjc0NjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ab633dc2ce5a1f71296b255d2e11378e7712d57fb85e2384cb767dcc95794c76 |
| hovercard-subject-tag | issue:1452482956 |
| 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/99554/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dd662dc20d84c621efc8e2d1f54973ab4f9f3bc52bb5d0ad844c8c99675d32c4/python/cpython/issues/99554 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dd662dc20d84c621efc8e2d1f54973ab4f9f3bc52bb5d0ad844c8c99675d32c4/python/cpython/issues/99554 |
| og:image:alt | Python 3.11 made .pyc files almost twice as large. There are two main reasons for this: PEP 659 made the bytecode stream ~3x as large as 3.10. PEP 657 made the location tables ~9x as large as 3.10.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brandtbucher |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0e60568924309a021b51adabdce15c2a2f285b556f3130d1a2fa2a5bce11c55f |
| 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 | dd206f7ed6207863172be4a783826e86bd2375c3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width