[Cython] template types
Robert Bradshaw
robertwb at math.washington.edu
Wed May 6 09:57:08 CEST 2009
On May 6, 2009, at 12:47 AM, Dag Sverre Seljebotn wrote:
> Stefan Behnel wrote:
>> I wouldn't care so much about that for now. Whatever declaration we
>> choose, it's easily added when the feature itself is there, and I
>> think
>> parametrised types are such an advanced feature that users can
>> well wait
>> for it to become available in pure Python mode.
>>
>> The priorities should be to make the feature simple and well
>> readable in
>> Cython code, and then 'somehow' available in Python code.
>
> I disagree with this principle. (I guess it might be a matter of taste
> in the end, so I'll just state my opinion and try not to drag this on
> for too long.)
>
> In perhaps about a year, with Python 3 argument decorators (def foo(x:
> int) -> float) and a bit of type inference, "pure Python mode" could
> actually become as convenient as Cython syntax and the preferred
> syntax
> we'd teach new users in my opinion.
I think "cdef int i,j,k" is in always going to be easier than
i = cython.declare(int)
j = cython.declare(int)
k = cython.declare(int)
but in general I agree with this philosophy.
> And anyway, I'm in favor of avoiding to have to invent two kinds of
> syntax for new features. Especially when the benefits are so small!
> (One
> uses a template a lot more than writing them.)
I'm guessing you mean you're *not* in favor?
> It's just a mess to have to tell users "this one is the Cython syntax
> but you can also use this one for Python compatability" etc.; that
> problem is there to stay but I don't see the sense of keeping
> adding to it.
Only if there's a non-pure Python syntax that's a lot cleaner (which
I think the class Foo[T] is).
- Robert
More information about the Cython-dev
mailing list