On Wed, Aug 18, 2010 at 7:14 AM, Lisandro Dalcin <[email protected]> wrote: > On 18 August 2010 01:30, Robert Bradshaw <[email protected]> wrote: >> On Tue, Aug 17, 2010 at 7:43 PM, Lisandro Dalcin <[email protected]> wrote: >>> I'm working on a patch trying to (you know me!) silent GCC unused >>> warnings for special methods like __idiv__/__div__ that get generated >>> but not used under a Py 3 runtime... >> >> Yay. >> >>> In the process, I would like to >>> make a little cleanup in TypeSlots.py... One of these cleanups, is >>> related to the 'flag' argument to SlotDescriptor.__init__() .. >>> Currently, it's only usage is to conditionally fill the nb_index slot. >>> >>> In short, instead of defining the slot as: >>> >>> MethodSlot(unaryfunc, "nb_index", "__index__", flag = >>> "Py_TPFLAGS_HAVE_INDEX") >>> >>> I'll do it like this: >>> >>> MethodSlot(unaryfunc, "nb_index", "__index__", ifdef = >>> ""PY_VERSION_HEX >= 0x02050000"") >>> >>> >>> Comments ? >> >> I think Py_TPFLAGS_HAVE_INDEX is more explicit, >> > > This macro is not defined in Py<2.5, Cython defines it to 0 (zero) in > Py3 ...
Yeah, I guess that should have been obvious. Given that the semantics are more completed than a single version comparison (I'm guessing 2.5 <= version < 3.0) it's probably worth making it a macro we define ourselves, like CYTHON_TPFLAGS_HAVE_INDEX. > This is contrary to the way Py_TPFLAGS_HAVE_NEWBUFFER is > defined (by Cython) to 0 in both Py<2.6 and Py3. I really like to > review these inconsistencies. But a necesary previous step is to get > rid of unnecesary usages of Py_TPFLAGS_HAVE_INDEX. > >> so I prefer that, but >> can't you use the latter form when there isn't already a flag? That's >> orthogonal to the name, which I could go either way on. >> > > Yes, basically I'm trying to conditionally fill the slot based on > Python version, and not in the definition/value of > Py_TPFLAGS_HAVE_INDEX. I had missed the obvious point that Py_TPFLAGS_HAVE_INDEX isn't going to be defined in pre-__index__ versions, which makes Py_TPFLAGS_HAVE_INDEX not the best to use. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
