Erik Bray schrieb am 24.11.2017 um 13:44:
> I think maybe I've seen this brought up once or twice before in the
> past, but with no real discussion.  There is a slightly unpythonic
> problem with using cpdef inline functions defined in a .pxd file that
> happen to access global variables.  For example:
> 
> $ cat foo.pxd
> FOO_A = 1
> 
> cpdef inline foo():
>     return FOO_A

Hmm, I might be missing something, but it feels like globals in a .pxd file
should not be allowed in the first place - unless there is a .pyx file for
them. But that's difficult to prohibit, given that the .pyx file is not
needed at compile time, and might not be there at all, just the readily
compiled module (and maybe not even that).

And I don't see why Python globals should be allowed in .pxd files at all.

So - it seems probably difficult to improve the first case. Regarding your
actual example, however, if there is really no use case for Python globals
in .pxd files, then we should better disallow them.

Stefan
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to