Title: gh-92041: Resolve registered frames from verified globals ownership by mdeck · Pull Request #160254 · python/cpython · GitHub
Open Graph Title: gh-92041: Resolve registered frames from verified globals ownership by mdeck · Pull Request #160254 · python/cpython
X Title: gh-92041: Resolve registered frames from verified globals ownership by mdeck · Pull Request #160254 · python/cpython
Description: Resolve registered frames and tracebacks directly from their globals owner when the registered module identity and normalized filename match. This avoids scanning sys.modules and gives a verified owner consistent precedence over a conflicting filename-cache entry. Successful ownership resolution does not populate the shared filename map, so bare code-object lookup remains filename based and is not changed by this fast path. A cached exact module with the frame's identical globals can be returned immediately: it cannot conceal a different globals owner, and the existing filename fallback would return that same module. Other cached results still require ownership verification. Private execution namespaces, mismatched origins, module subclasses, dynamic filenames, fileless modules and unrelated filename overrides retain the filename fallback. Source/bytecode normalization is preserved. Source retrieval is unchanged, including linecache.getlines() overrides and the module globals passed to them. Documentation and NEWS describe the ownership precedence directly. This implements the frame/traceback split discussed in #92042. It remains independent of and complementary to #156685; the changes compose cleanly in either order. No registry watchers, C changes or negative caching are included. Performance Measurements use source-pinned variants in one CPython 3.16 -O3 Linux build without PGO/LTO. Eight fresh processes use counterbalanced ABBA/BAAB batches; intervals are 95% process-level bootstrap intervals, with all samples retained and identical-code controls. Direct registered-frame lookup with warm filename caches: about 2.04 µs on the pinned mainline versus 0.40 µs with this revision; paired time ratio 0.199 (0.195–0.203), approximately 5× faster. Four-frame source-context stack with warm filename/source caches: paired time ratio 1.002 (0.992–1.012) versus mainline. No statistically resolved regression; smaller effects remain unresolved. The same stack with #156685 composed: ratio 1.006 (0.996–1.016) versus that replacement alone. Explicit cached frame lookup: about 0.271 → 0.266 µs. Ordinary-function lookup costs about 11 ns more; warm code-object lookup about 15 ns more. Ownership verification has costs on fallback paths: explicit cached private-namespace lookup about 0.275 → 0.508 µs, and a registered frame executing a different source file about 0.280 → 1.512 µs. These paths are not claimed as performance improvements. These are microbenchmark results for the specified workloads, not an application-wide speedup. Earlier cold-registry measurements linked in the discussion concern earlier source snapshots and are not presented as measurements of this revision. Validation Six suites pass standalone and composed with #156685: inspect, zipimport support, import, linecache, traceback and pydoc. Each run reports 1,149 tests, 4 skipped, with --fail-env-changed. 648 cold differential cases preserve mainline behavior outside the intended collision change. 5,184 cached cases preserve the preceding ownership revision's results. Regression coverage includes conflicting cached modules, module subclasses spoofing globals, source/bytecode aliases, explicit filename overrides, registry replacement and linecache.getlines() hooks receiving the frame owner's globals. Configured lint hooks and git diff --check pass. Native build, normal documentation HTML and changelog builds pass. The project's documentation warning gate passes; existing baseline nitpicky warnings remain. Developed and tested with Codex (AI assistance). Issue: gh-92041
Open Graph Description: Resolve registered frames and tracebacks directly from their globals owner when the registered module identity and normalized filename match. This avoids scanning sys.modules and gives a verified o...
X Description: Resolve registered frames and tracebacks directly from their globals owner when the registered module identity and normalized filename match. This avoids scanning sys.modules and gives a verified o...
Opengraph URL: https://github.com/python/cpython/pull/160254
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
| react-profiling | 0 |
| react-import-map | react,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-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8480d8e0-137c-25bf-9519-6b154e3f8dc9 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D276:1CA0E6:D4A5FE:121071F:6B064E24 |
| html-safe-nonce | fd12c6d10d698f07c512cb66b32f85217f57113ad15ee5dbb02c8e391028706c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjc2OjFDQTBFNjpENEE1RkU6MTIxMDcxRjo2QjA2NEUyNCIsInZpc2l0b3JfaWQiOiI0MTI4OTU2MzU3ODU0Nzc2ODY4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1df767249b3b079a91536e1805b2780285c81a258bb7d4261c6c80ad471d9574 |
| hovercard-subject-tag | pull_request:4969579266 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/160254/files |
| twitter:image | https://avatars.githubusercontent.com/u/1872833?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1872833?s=400&v=4 |
| og:image:alt | Resolve registered frames and tracebacks directly from their globals owner when the registered module identity and normalized filename match. This avoids scanning sys.modules and gives a verified o... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f1f9a08f7c769a37f1dfc18ad43d463c222a7eea |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width