Robert Bradshaw, 05.04.2010 21:00:
> On Apr 5, 2010, at 9:31 AM, Haoyu Bai wrote:
>> Additionally, I think it is better to have
>> something like a CythonModule.py as a counterpart of the Shadow.py,
>> then it is easy to assure the content of the 'cython' module is the
>> same between Cython and pure Python mode.
>
> I'm not convinced that grouping internal Cython constructions based on
> whether they have a "pure" counterpart is the best way to do things--
> in my ind the directives having to do with division are best handled
> in the division node, those dealing with buffers best handled in the
> buffer code, etc.
+1
It's nice to have a simple language interface to all these features, but
that doesn't mean they have to be any similar on the implementation side.
>> What to do if you have:
>>
>> import cython as C
>> ...
>> C = 'foo'
>> ...
>>
>> or similar thing like:
>>
>> import cython
>> ...
>> foo = cython.cdef
>> ...
>
> from cython import cclass
>
> if random.random()< 0.5:
> cclass = lambda x: x
>
> %cclass:
> class Foo:
> ...
I was about to say that these things would require at least a full featured
flow control analysis mechanism, but it's true that there will always be
cases where this can't be solved at all.
> I think it's much safer to simply forbid "from cython import *",
> especially as its contents may change with time.
+1
I'm even fine with forbidding reassignments to names imported from the
cython namespace. The cython module is special in every way, so making it
just a bit more special so that we can simplify the compiler sounds
reasonable to me. I can't imagine any use case for any of the above
examples. When we find them in code, it's almost certainly a bug that
Cython should bark at.
>> This may be the best we can do. Of course, one can always do
>> exec('cython = "foo" '), well...
>
> At least Cython wouldn't choke on that.
... and that's not even because it can't currently work. ;)
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev