Re: [Sqlalchemy-tickets] [sqlalchemy] #2161: Py3k support for the C extension
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-07-04 18:31:13
|
#2161: Py3k support for the C extension
-------------------------------+-------------------------------
Reporter: ged | Owner: pjenvey
Type: enhancement | Status: new
Priority: medium | Milestone: 0.9.xx
Component: cextensions | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: needs review |
-------------------------------+-------------------------------
Comment (by claudiofreire):
Replying to [comment:6 taavi]:
> Regarding {{{PyObject_HEAD_INIT}}}, looking at Python-2.6.2 vs
Python-3.2, both in {{{Include/object.h}}}, I can see why you'd make the
change from {{{PyObject_HEAD_INIT(type), 0}}} to
{{{PyVarObject_HEAD_INIT(type, 0)}}}. On Py2k they generate identical code
to the compiler by definition:
> {{{
> #define PyVarObject_HEAD_INIT(type, size) \
> PyObject_HEAD_INIT(type) size,
> }}}
>
> And that's NOT the case in Py3k (things get wrapped in an extra set of
curlies):
> {{{
> #define PyVarObject_HEAD_INIT(type, size) \
> { PyObject_HEAD_INIT(type) size },
> }}}
>
> If {{{PyVarObject_HEAD_INIT}}} is the right thing to use in Py3k, then
we should also use it in Py2k.
So, this is py3:
{{{
#ifdef Py_LIMITED_API
typedef struct _typeobject PyTypeObject; /* opaque */
#else
typedef struct _typeobject {
PyObject_VAR_HEAD
}}}
And this is py2
{{{
typedef struct _typeobject {
PyObject_VAR_HEAD
}}}
In both cases, it's variable size. This is done for base classes, which
are stored in tuple-fashion, after the type object's struct.
So, the correct thing is indeed to use VAR.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2161#comment:24>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|