Dag Sverre Seljebotn wrote:
> Craig Citro wrote:
>   
>> I have a question about the semantics of mixing imports and cimports.
>> I started drafting a long message with lots of details and examples,
>> but I realized I should just start with a few simple questions: if you
>> do
>>
>> from Foo import Bar
>> from Foo cimport Bar
>>
>> in a .pyx file, is it safe to assume that the Bar we import at runtime
>> is going to be coming from the same module whose .pxd we analyzed at
>> compile-time? Is it at least safe to assume that the Bar we import at
>> runtime will be the same *type* as the Bar we saw at compile-time?
>> (The next obvious question: what other information can we assume is
>> the same?)
>>   
>>     
> I can't help you, but: If not much is assumed at the moment, my vote is 
> to be able to start assuming stuff (and that the backwards compatability 
> breakage is a sacrifice one can make).
>
> Basically, if a pxd and a Python module has the same name, assume that 
> the pxd file is written with detailed knowledge of what goes on in the 
> Python module, and exists to provide hints to Cython about faster execution.
>   
One thing that is relevant: If you do

cdef extern from ...:
    cdef class numpy.ndarray...

or something like that (see numpy.pxd), then "numpy.ndarray" will be 
assumed to have the right type object (and this is checked at module 
import time). But this is through the "extern cdef class" statement, and 
not because the pxd has the same name as the Python module.

Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to