[Python-Dev] PyRange_New() alternative?
Scott David Daniels
Scott.Daniels at Acm.Org
Sat Jun 24 02:14:25 CEST 2006
Ralf W. Grosse-Kunstleve wrote:
> Thanks! This does the trick for me:
>
> #if PY_VERSION_HEX >= 0x02030000
> PyObject_CallFunction(
> (PyObject*) &PyRange_Type, "lll", start, start+len*step, step)
> #else
> PyRange_New(start, len, step, 1)
> #endif
>
> I am compiling the code above with a C++ compiler (in the context of
> Boost.Python). Newer g++ versions unfortunatly produce a warning if -Wall is
> specified:
>
> warning: dereferencing type-punned pointer will break strict-aliasing rules
I am not sure about your compiler, but if I remember the standard
correctly, the following code shouldn't complain:
PyObject_CallFunction((PyObject*) (void *) &PyRange_Type,
"lll", start, start+len*step, step)
-- Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-Dev
mailing list