3 ms·
I gather that BINARY_SUBTRACT in this context means type-independent subtraction of two operands. Not subtraction of two binary integers. So we aren't yet seein
by Animats 6y ago
I gather that BINARY_SUBTRACT in this context means type-independent subtraction of two operands. Not subtraction of two binary integers. So we aren't yet seeing the dispatching which decides what type of subtraction to do. Integers? Floats? Strings? Some object that defines subtraction?
An important thing to realize about CPython's implementation is that almost everything is really a key/value map underneath. Which is why number-crunching has to be done in C.
- KMag 6y agoMore importantly, even small integers are heap-allocated. Some are pre-allocated and reused (0 to 100, IIRC), but outside of that, every numeric result requires a malloc and object initialization.
- BerislavLopac 6y ago-5 to 256
- akx 6y agoNot exactly. Small objects are allocated using an internal arena allocator called pymalloc: https://docs.python.org/3/c-api/memory.html#the-pymalloc-allocator https://docs.python.org/3/c-api/memory.html#the-pymalloc-all...