Expand description
Values this crate does not know the shape of.
A Python program needs objects that are not data: the function print is
bound to, the iterator a for loop walks, the exception a raise throws.
None of them can be built here. There are no classes yet, so there is no way
to define a type from inside Python, and the ones the runtime needs depend
on the runtime rather than on the object model. print has to know where the
output goes and an iterator has to know how the interpreter steps it.
Growing an Object variant for each of them would put every
one of those decisions in this crate, which is the wrong place for them and
is the sort of thing that is easy to add and hard to take back out. So the
layer above defines the type, implements Native, and this crate asks it
the same handful of questions it asks any other value.
Getting the concrete type back out is Native::as_any and a downcast.
That is the cost of the arrangement and it is paid only by the runtime, at
the two or three places that have to know whether the thing in a register is
the kind of object they can call or step.
§Identity, equality and hashing
All three are the address, and none of them can be overridden. A function is
equal to itself and to nothing else, and that is what CPython says for one
too. When classes arrive and __eq__ becomes user code the question moves
to the class rather than to this trait, so there is no point in an
overridable answer here that would have to be taken away again.
Traits§
- Native
- A value whose type lives above this crate.