Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Vitja Makarov <vitja.makarov-Re5JQEeQqe8AvxtiuMwx3w <at> public.gmane.org>
Subject: Re: [Cython] ComprehensionNode problem
Newsgroups: gmane.comp.python.cython.devel
Date: Friday 2nd September 2011 06:06:50 UTC (over 5 years ago)
2011/9/2 Robert Bradshaw
:
> On Sun, Aug 28, 2011 at 1:19 PM, Vitja Makarov
 wrote:
>> I've started #715 ticket investigation.
>>
>>
>> Here is minimal test case:
>>
>> # cython: language_level=3
>> def foo(target):
>>    return [(e for e in t) for t in target]
>>
>> Crash in the ticket is related to GeneratorExpressionScope (name is
>> not correct, actually ScopedExprScope or NestedScope)
>>
>> If you set languange_level to 2 you will see next error:
>> ...
>> Compiler crash traceback from this point on:
>>  File "/home/vitja/work/cython-vitek-git/Cython/Compiler/ExprNodes.py",
>> line 7732, in __init__
>>    if not result_type.create_from_py_utility_code(env):
>> AttributeError: 'UnspecifiedType' object has no attribute
>> 'create_from_py_utility_code'
>>
>>
>> Since ComprehensionNode.append and ComprehensionNode.loop.body is the
>> same generator body is created twice in MarkClosureVisitor
>>
>> So the issue could be solved in two ways:
>>
>>  - Write special handler for ComprehensionNode in MarkClosureVisitor
>>  - Remove append child attribute from ComprehensionNode (it can be
>> removed completely or just from children attribute list)
>
> +1 to the latter option (which I see is what you did, thanks).
>

Thanks!

I've also found one interesting bug in genexpr implementation

http://trac.cython.org/cython_trac/ticket/724


In CPython iterator is evaluated before genexpr is created.

class Foo:
    def __iter__(self):
        print 'iter'
        return self

    def next(self):
        return 1

g = (i for i in Foo())
print g

will print in cpython:
iter


and in cython:


Don't know how to deal with it now.

-- 
vitja.
 
CD: 17ms