GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-139847: Add PyType_Lookup() function by vstinner · Pull Request #139848 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Oct 9, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: [C API] Add PyType_Lookup() function #139847

📚 Documentation preview 📚: https://cpython-previews--139848.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-139847: Add PyType_Lookup() function
480faa6
@vstinner vstinner added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API labels Oct 9, 2025
@vstinner
vstinner requested review from AA-Turner and markshannon as code owners October 9, 2025 13:51
@bedevere-app bedevere-app Bot mentioned this pull request Oct 9, 2025
[C API] Add PyType_Lookup() function #139847
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 9, 2025
@vstinner
Fix the function name in the NEWS entry
1303db2
@vstinner vstinner removed the type-feature A feature request or enhancement label Oct 9, 2025
colesbury
colesbury reviewed Oct 9, 2025
View reviewed changes
Comment thread Doc/c-api/type.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

vstinner and others added 2 commits October 9, 2025 20:49
@vstinner @colesbury
Update Doc/c-api/type.rst
1c3e523
Co-authored-by: Sam Gross <[email protected]>
@vstinner
Doc: link to PyObject_GetOptionalAttr()
8f24f7a
@vstinner vstinner added type-feature A feature request or enhancement awaiting merge labels Oct 9, 2025
@vstinner

vstinner commented Oct 9, 2025

Copy link
Copy Markdown
Member Author

Check labels / Unresolved review (pull_request): Failing after 6s

The CI fails with:

Error: Label error. Requires exactly 1 of: awaiting merge. Found: type-feature, awaiting core review, interpreter-core, topic-C-API

I added the awaiting merge label to repair this CI.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Merge branch 'main' into type_lookup
daf8546
efimov-mikhail
efimov-mikhail reviewed Oct 11, 2025
View reviewed changes
Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

efimov-mikhail
efimov-mikhail reviewed Oct 11, 2025
View reviewed changes
Comment thread Modules/_testcapi/type.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

vstinner added 2 commits October 11, 2025 19:21
@vstinner
Don't schedule _PyType_Lookup() removal in this PR
c3b9324
@vstinner
Revert Doc/whatsnew/3.15.rst changes
01a141f
@vstinner

vstinner commented Oct 11, 2025

Copy link
Copy Markdown
Member Author

I reverted changes to schedule _PyType_Lookup() and _PyType_LookupRef() removal, just to make this PR easier to review and more "atomic". I prefer to write a separated PR for the removal.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Oct 14, 2025

Copy link
Copy Markdown
Member Author

@encukou: So what do you think of exposing this PyType function?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou

encukou commented Oct 14, 2025

Copy link
Copy Markdown
Member

I think there's benefit to exposing this but we need to do it carefully. The operation is different from getattr in surprising ways. The docs & tests should mention details -- not invoking descriptors or metaclass getattr. It might also be good for the docs to add an example of where Python uses this operaton, and/or equivalent Python code.

“Lookup” is a new term in the public C API; are we sure this is the right operation for the name?

efimov-mikhail reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Do not invoke descriptors or metaclass __getattr__()
1290171
Add Python pseudo-code in the doc.
@vstinner

vstinner commented Oct 14, 2025

Copy link
Copy Markdown
Member Author

The docs & tests should mention details -- not invoking descriptors or metaclass getattr.

Good idea. I added tests for that and completed the doc.

It might also be good for the docs to add an example of where Python uses this operaton, and/or equivalent Python code.

I added Python pseudo-code to the doc.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Oct 16, 2025
Add PyType_Lookup() function capi-workgroup/decisions#83
Closed
2 of 5 tasks
encukou
encukou reviewed Jan 13, 2026
View reviewed changes
Comment thread Doc/c-api/type.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vstinner @encukou
Update Doc/c-api/type.rst
2cc877c
Co-authored-by: Petr Viktorin <[email protected]>
@vstinner

vstinner commented Feb 10, 2026

Copy link
Copy Markdown
Member Author

The issue was closed, so I close the PR as well: #139847 (comment).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner closed this Feb 10, 2026
@vstinner
vstinner deleted the type_lookup branch July 10, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou left review comments
@colesbury colesbury colesbury left review comments
@efimov-mikhail efimov-mikhail efimov-mikhail left review comments
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review awaiting merge interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@vstinner @encukou @colesbury @efimov-mikhail
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.