[pypy-issue] [issue1122] [cpyext] PyVarObject builtins and definition of Py_SIZE()
tracker at bugs.pypy.org
Tue Apr 10 22:50:51 CEST 2012
New submission from Stefan Behnel <stefan_ml at behnel.de>:
I wonder why the definition of PyTupleObject and friends use PyObject_HEAD
instead of PyObject_VAR_HEAD - how is Py_SIZE(atuple) supposed to work?
Py_SIZE() is currently defined like this:
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
i.e. it actually requires a PyVarObject struct. That macro works with quite a
number of builtin types in CPython, but it can't work for them in PyPy.
Personally, I wouldn't mind adding the ob_size field to at least the constant
sequence types as a duplication of the object length value, because it would
allow for a similar optimisation of the couple of Py(Tuple|Bytes|Unicode|maybe
others)_GET_SIZE() macros as for the ones in issue1121, by simply aliasing them
to Py_SIZE(). C extensions commonly expect these macros to be fast.
nosy: pypy-issue, sbehnel
title: [cpyext] PyVarObject builtins and definition of Py_SIZE()
PyPy bug tracker <tracker at bugs.pypy.org>
More information about the pypy-issue