Greg Ewing wrote:
> Dag Sverre Seljebotn wrote:
>
>> cdef extern from *:
>>     ctypedef rank("mylib", 3) smallint
>>     ctypedef rank("mylib", 4) largeint
>
> Do you have any use cases where that would actually
> be helpful? I.e. where you don't know the exact types
> but you are sure of their ranking, and knowing the
> ranking is useful?

I mentioned the C99 types which is such a case; they add at least three
"rank-groups": int32_t and so on, int_least32_t and so on, and
int_fast32_t and so on.

Something very similar is going on in numpy.pxd (shipped with Cython),
since the NumPy C headers go to great pains to define these in a
cross-platform way (i.e. numpy.int32_t and so on is defined). In addition,
numpy.pxd defines float32_t, float64_t, which AFAIK is not part of C99.

Stefan Behnel wrote:
> Dag Sverre Seljebotn wrote:
>> cdef extern from *:
>>     ctypedef rank("mylib", 3) smallint
>>     ctypedef rank("mylib", 4) largeint
>
> ... looks like implementation detail leakage to me ...

Hmm; all that is needed is a syntax though. Other alternatives:

cdef extern from *:
    ctypedefgroup:
        int smallint
        int largerint

or:

cdef extern from *:
    ctypedef some int smallint
    ctypedef some int largerint
    ctyperelationship smallint < largerint

or similar ideas, I believe the point is taken, although I don't like
either of these concrete proposals.

Dag Sverre

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to