-
-
Save undingen/74f15bbbe2ebbf9fe442 to your computer and use it in GitHub Desktop.
same_slots_added
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int same_slots_added(PyTypeObject* a, PyTypeObject* b) noexcept { | |
PyTypeObject* base = a->tp_base; | |
Py_ssize_t size; | |
PyObject* slots_a, *slots_b; | |
assert(base == b->tp_base); | |
size = base->tp_basicsize; | |
if (a->tp_dictoffset == size && b->tp_dictoffset == size) | |
size += sizeof(PyObject*); | |
// Pyston change: have to check attrs_offset | |
if (a->attrs_offset == size && b->attrs_offset == size) | |
size += sizeof(HCAttrs); | |
if (a->tp_weaklistoffset == size && b->tp_weaklistoffset == size) | |
size += sizeof(PyObject*); | |
/* Check slots compliance */ | |
slots_a = ((PyHeapTypeObject*)a)->ht_slots; | |
slots_b = ((PyHeapTypeObject*)b)->ht_slots; | |
if (slots_a && slots_b) { | |
if (PyObject_Compare(slots_a, slots_b) != 0) | |
return 0; | |
size += sizeof(PyObject*) * PyTuple_GET_SIZE(slots_a); | |
} | |
return size == a->tp_basicsize && size == b->tp_basicsize; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment