Hi, Dag Sverre Seljebotn wrote: > I'm combining many emails into one.
Separating them again. :) > Stefan wrote: (mind the -f-) >>> def foo(a : unicode): >>> >>> would make sure int and str params are converted to unicode. >> No way. Converting a byte string to unicode is something that has to be >> done >> explicitly. How could you know the input encoding that is used for the >> byte sequence? > > It wasn't a proposed or wanted functionality, it was only a demonstration > of the fact that as a Python user, if > > def f(a: cython.types.int): > ... > > automatically construct a Cython int on entering, I kind of expect to be > able to do: > > def twice_factory(x): return cython.types.int(x) * 2 > > def f(a: twice_factory): > ... > > And have f automatically have its argument doubled No. Honestly. If you want such a functionality, write a decorator, but don't stuff the language with it. It's perfectly fine and a great feature that Cython can do C-to-Python-and-back-again type conversion on the fly. But allowing anything beyond that would be too much magic without any compelling use case. And I actually think that the syntax that we choose should not suggest stupid things. That's one reason why I dislike the assignment syntax. Your example > def twice_factory(x): return cython.types.int(x) * 2 is a *very* good example for something completely meaningless that this syntax suggests to users. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
