Craig Citro wrote:
>
>> Hmm. In my experience the return value of functions is much more
>> important though, and how can one possibly get those through
>> introspection? So I'm unsure about the gain...
>>
>>     
>
> I guess I'm not sure what you mean by introspection here. I was
> thinking of being able to decorate imports in a .pyx file (or even .py
> or .pxd, really) to say "go ahead and analyze these at compile-time,"
> specifically to do things like determine return types. It's true that
> in many cases you couldn't come up with much ... it's definitely
> something we'd want as an "opt-in" thing, because it could be
> extremely expensive for little gain.
>   
With introspection I mean exactly what you say. I'm just not familiar 
with any methods to figure out return types of existing Python code.

If I have foo.py containing

def f(x):
    print x
    return 3

how do you analyze that the return type is int? I could have an if-test 
on x, so calling it won't help you, and the "inspect" module only gives 
you the number of arguments and so on...

You could disassemble the byte-code or parse the Python source and then 
do analysis, but I'm assuming you're not volunteering for that... :-)

Do mean providing a set of annotations for pure Python code, so that we 
can read

def f(x: cython.int) -> cython.int

in a pure Python file (using the Cython shadow module), and understand it?

If so, +1.


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

Reply via email to