-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Mypyc Object Representation
Mypyc uses a tagged pointer representation for values of type int
(CPyTagged
), char
for booleans, and C structs for tuples. For most
other objects mypyc uses the CPython PyObject *
.
Python integers that fit in 31/63 bits (depending on whether we are on
a 32-bit or 64-bit platform) are represented as C integers
(CPyTagged
) shifted left by 1. Integers that don't fit in this
representation are represented as pointers to a PyObject *
(this is
always a Python int
object) with the least significant bit
set. Tagged integer operations are defined in mypyc/lib-rt/int_ops.c
and mypyc/lib-rt/CPy.h
.
There are also low-level integer types, such as int32
(see
mypyc.ir.rtypes
), that don't use the tagged representation. These
types are not exposed to users, but they are used in generated code.