Skip to content

__class__ and type() #2189

Feb 25, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Is this a PyO3 thing? It smells like the Python interpreter querying private state on the object vs asking the object what type it is. It isn't a dealbreaker but I figured I'd ask.

Python interpreter querying private state on the object is exactly what it is. Here's the relevant line of C in the implementation of the type builtin:

https://github.com/python/cpython/blob/87af12bff33b3e7546fa26158b7d8680ecb6ecec/Objects/typeobject.c#L3343

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mattgreen
Comment options

Answer selected by mattgreen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants