Robert wrote: > On May 15, 2009, at 11:41 AM, Lisandro Dalcin wrote: > >> On Fri, May 15, 2009 at 2:03 PM, Dag Sverre Seljebotn >> <[email protected]> wrote: >>> Lisandro wrote: >>> >>> I tried proposing something similar (unknown size) some time ago >>> and it >>> was voted down; perhaps the climate has changed now. >> >> I voted it down perhaps because I misunderstood your proposal. I >> understood you were proposing this for the whole type system. >> >> If this is done for external ctypedefs, I would no oppose it. > > I just don't see how such a construct would be useful. For everything > that can be deferred to using sizeof (e.g. conversion to/from Python) > we are moving to using just this, not using the ranking information > at all, so there's no gain. Now for the stuff where we do use ranking > information (only temps and type inference come to mind) we either > use the ranking the user gave (and blame them if they gave it wrong > enough that it messed them up) or disallow, e.g., all arithmetic > between unranked and ranked types. Thus
What you are missing here is mixing external typedefs (for which a coherent ranking can be assigned as a closed system, sure) with pure builtin types. cdef np.int32_t a = ... cdef long b = ... b = a / b NOTE: This is also relevant for Cython itself without any external typedefs, as it would be nice to support C99 int32_t, int64_t etc., but we have no idea how to rank them relative to existing integer types. For the overview, here's three solutions: A) Document, document, document; the behaviour is difficult to understand but at least we are clear about it B) Accept that Cython becomes part of the final compilation stage with #ifdefs and exact types; this will happen anyway if Cython parses .h files!! C) Trick around the temps as well with some ugly kludge to make ranking information unecessarry (though nice to have if available because nicer code is generated). (I'm feeling up one more but it's still very hazy.) There's lots of options for C). In addition to what has been mentioned; if one accept a small ./configure-style prestep, one could e.g. write a program to output a header file containing #define sizeof_IntA 4 ...and so on. That would do wonders, as you could get widest_IntA_IntB as a typedef. Note that in C++ this *might* be less of a problem because one could likely use template techniques to construct the temps one needs...though I didn't try. Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
