__class__ and type() #2189
-
I'm working on a Python binding to a DSL. It exposes proxies to "objects" in Rust code, which are structures with an The Rust-side objects can change their type during runtime. This causes their Python proxies to get out of sync: an After too much head-scratching, I realized PyO3 lets you override 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. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
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