[Cython] inline defnode calls
mark florisson
markflorisson88 at gmail.com
Wed Jan 25 11:44:40 CET 2012
On 25 January 2012 06:49, Vitja Makarov <vitja.makarov at gmail.com> wrote:
> 2012/1/25 mark florisson <markflorisson88 at gmail.com>:
>> I just noticed the inline defnode call code. When I try to compile
>> with 'cython -Xoptimize.inline_defnode_calls=True test.pyx' with the
>> following code:
>>
>> def foo(x): print foo
>> foo(10)
>>
>> I get
>>
>> Error compiling Cython file:
>> ------------------------------------------------------------
>> ...
>> def foo(x):
>> print x
>>
>> foo(10)
>> ^
>> ------------------------------------------------------------
>>
>> test.pyx:4:3: Compiler crash in InlineDefNodeCalls
>>
>> ModuleNode.body = StatListNode(test.pyx:1:0)
>> StatListNode.stats[2] = ExprStatNode(test.pyx:4:3)
>> ExprStatNode.expr = SimpleCallNode(test.pyx:4:3,
>> result_is_used = True,
>> use_managed_ref = True)
>>
>> Compiler crash traceback from this point on:
>> File "/Users/mark/cy/Cython/Compiler/Visitor.py", line 176, in _visitchild
>> result = handler_method(child)
>> File "/Users/mark/cy/Cython/Compiler/Optimize.py", line 1656, in
>> visit_SimpleCallNode
>> if not function_name.cf_state.is_single:
>> AttributeError: 'NoneType' object has no attribute 'is_single'
>
>
> Thanks for the report! The feature is still experimental and by
> default is disabled.
> Anyway it wouldn't work for your example. It works when we know what
> exactly function is referred by the name so it's closure case:
>
> def foo():
> def bar():
> pass
> bar()
>
> --
> vitja.
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
Ah, neat. I thought it was perhaps also defying monkeypatching.
More information about the cython-devel
mailing list