PEP 208 - NewStyleNumber

Joakim Hove hove at phys.ntnu.no
Fri Aug 30 15:38:16 CEST 2002


Hello,

I am trying to implement an extension class which should support the
PEP 208 notion of NEWSTYLENUMBER, i.e. a the fundamental arithmetic
operations should accept different types without coercion.

However when I define my object as:

    static PyTypeObject ETuple_Type = {
        PyObject_HEAD_INIT(NULL)
        0,
        "ETuple",
        sizeof(ETuple_Object),
        0,
        (destructor) ETuple_dealloc,      /*tp_dealloc*/
        (printfunc)  ETuple_print,        /*tp_print*/
        (getattrfunc)ETuple_getattr,  /*tp_getattr*/
        (setattrfunc)ETuple_setattr, /*tp_setattr*/
        0,            	 /*tp_compare*/
        0,                   /*tp_repr*/
        &ETuple_Numeric,     /*tp_as_number*/
        0,          	 /*tp_as_sequence*/
        0,          	 /*tp_as_mapping*/
        0,                 	 /*tp_hash */
        0,
        (reprfunc)   ETuple_str,          /*tp_str*/
        0,
        0,
        0,
        Py_TPFLAGS_NEWSTYLENUMBER
    };  


And include the Python-2.2 headers, the compilation fails:

 /--------------------------------------------------
 |bash% cc -O2 -I/usr/local/include/python2.2  -c libETuple.c
 |cc-1020 cc: ERROR File = libETuple.c, Line = 200
 |  The identifier "Py_TPFLAGS_NEWSTYLENUMBER" is undefined.
 |
 |      Py_TPFLAGS_NEWSTYLENUMBER
 |      ^
 |
 |1 error detected in the compilation of "libETuple.c".
 \--------------------------------------------------

i.e. it seems as the newstylenumbers is not defined after all - am I
misunderstanding something - has the feature been backed out again
from Python-2.1??


Best Regards


Joakim Hove

-- 
==== Joakim Hove      www.phys.ntnu.no/~hove/   =======================
|| Institutt for fysikk  (735) 93637 / E3-141  |  Skøyensgate 10D    ||
|| N - 7491 Trondheim    hove at phys.ntnu.no     |  N - 7030 Trondheim ||
================================================= 73 93 31 68 =========



More information about the Python-list mailing list