I'm combining many emails into one. Robert: > Yeah, it could get ugly: cython.types.pointer(cython.types.pointer > (cython.types.int))."
I think "cython.types" is too longwinded anyway, in practice it would be: import cython.types as c c.ptr(c.ptr(c.int)) Which isn't *that* bad? And one could provide all kind of convenience pre-declared names: c.pint = c.ptr(c.int) c.ppint = ... c.pchar = ... c.ppchar = ... Perhaps just make a convention of providing up to three "ppp"-types for every type, and then have a parametrized type c.ptrs(6, c.int) if you really want to do int******. PChar is already a well-known synonym for char* in some codebases. >> 1) Don't type variables but use inference heavily >> 2) Explicitly typed variable names > > (1) can be done on pure Python code, but without any types to start > with it is fairly limited. I think specifying types in function > declarations can go a long way to make it powerful though. I think Yes, I meant type inference with: - Type constructors as conversion operators (a la C++) - A function decorator that passes the arguments to their decorators I.e. 1) has every possibility to be let the types be explicit, but through the normal Python way of doing that (ie not binding the variables to a type but making sure in code that one knows what type the objects are). This has the most Python feel to it and would make people quickly be able to use it - while the non-standard declare type syntax always is around if one prefers it. A last (desperate) syntax for type declarations: with cython.types.int as x, cython.types.int as y: (Some time since I read the with PEP so don't know if this is entirely right, think multiple statements are a proposed future feature or something.) Stephan wrote: >> >> 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 Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
