Dag Sverre Seljebotn wrote: > Feedback welcome on the below set of conventions -- I just picked some > conventions to get going and implemented them as they are easily > changeable.
Thanks for doing this. > Terminology first -- I don't really like the word pragma... "code > generation options" are perhaps better? I've called them "(compiler) > options" below and in the code base, while calling what is options today > "arguments" (as it is command line arguments they really are). I think a good term is "compiler directives". > Ways to set options: > > a) > > #cython: boundscheck=True, other=False > #cython: third = no > > before any code in the file (but whitespace is allowed, I'm using > Plex/the parser). The boolean value is case-insensitive and > true/false/yes/no is allowed (is this too much? The thing is, for > command-line arguments "True" is rather unfriendly and I'd like it to be > consistent). I would prefer having a strict Python syntax in the source, even if the cmd line handles it in a more relaxed way. > c) A decorator works on function-scope: > > cimport cython > @cython.boundscheck(True) > def f(): > ... > > The decorator is stripped away before the decorator transform. Nice. > There is > not really such symbol as cython.boundscheck in the scope, it is a magic > option only. So of course you cannot do > > a = cython.boundscheck > @a > ... Fine with me. > d) A with statement: > > cimport cython > with cython.boundscheck(False): > ... > > The entire with statement is then stripped out of the source prior to > the with transformation. Fine. We should take a little care that we document directives that cannot be used that way, e.g. because they only apply to functions and not to simple blocks (not sure we ever need that, just a side-note). > BTW, on "cimport cython": This is magic as well. I.e. it always is in > front of the include path, and there will be no way to have a pxd file > named "cython.pxd" imported. Is this OK? (I can change it but it would > be less simple in more than one place, and people really should always > have the cython scope available.) Having a cython.pxd would be nice for documentation purposes. However, I think it's perfectly ok to make it a virtual file as long as you have to cimport it before you can use it. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
