A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-June/066453.html below:

[Python-Dev] PyRange_New() alternative?

[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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4