[Cython] yield...

Dan Stromberg strombrg at gmail.com
Mon Feb 14 20:09:00 CET 2011


On Sun, Feb 13, 2011 at 9:55 PM, Vitja Makarov <vitja.makarov at gmail.com>wrote:

> 2011/2/14 Dan Stromberg <strombrg at gmail.com>:
> >
> > On Sun, Feb 13, 2011 at 5:17 PM, Dan Stromberg <strombrg at gmail.com>
> wrote:
> >>
> >> On Sun, Feb 6, 2011 at 3:38 AM, Vitja Makarov <vitja.makarov at gmail.com>
> >> wrote:
> >>>
> >>> 2011/2/6 Dan Stromberg <strombrg at gmail.com>:
> >>> >
> >>> > On Sat, Feb 5, 2011 at 3:10 PM, Vitja Makarov <
> vitja.makarov at gmail.com>
> >>> > wrote:
> >>> >>
> >>> >> 2011/2/6 Vitja Makarov <vitja.makarov at gmail.com>:
> >>> >> > 2011/2/6 Dan Stromberg <strombrg at gmail.com>:
> >>> >> >>
> >>> >> >> Just a quick note to let you know I'm very eager to have working
> >>> >> >> generators
> >>> >> >> (yield) in Cython... ^_^  It's frequently the main thing that
> >>> >> >> complicates
> >>> >> >> moving my critical sections to Cython.
> >>> >> >> --
> >>> >> >> Dan Stromberg
> >>> >> >>
> >>> >> >
> >>> >> > Ok, you will see generators soon in cython))) the most important
> >>> >> > part
> >>> >> > is already implemented, but I'm not sure that's the importetant
> >>> >> > one;)
> >>> >> >
> >>> >>
> >>> >> now you can use my github repo at https://github.com/vitek/cython
> >>> >
> >>> > Hey, that's great.
> >>> > I tried a little test program with it, and it worked great.  I'll
> >>> > likely
> >>> > give it a try with a more real-world workload before long.
> >>> > Does it pass all the tests you've thrown at it yet?
> >>> > Thanks!
> >>> >
> >>>
> >>> Hmm now it work as excepted. If you will find a case when it doesn't
> >>> work, report it.
> >>> See also tests at tests/run/generators.pyx
> >>>
> >>> --
> >>> vitja.
> >>
> >> Do you want e-mail, or a formal bug tracking entry?
> >> In case you want e-mail:
> >> + /usr/local/cpython-2.5/bin/python /usr/local/cpython-2.5/bin/cython
> >> rolling_checksum_pyx_mod.pyx
> >> Error compiling Cython file:
> >> ------------------------------------------------------------
> >> ...
> >> import os
> >> import sys
> >> #mport comma_mod
> >> def min_max_chunker(file_handle):
> >> ^
> >> ------------------------------------------------------------
> >> rolling_checksum_pyx_mod.pyx:9:0: Compiler crash in MarkClosureVisitor
> >> ModuleNode.body = StatListNode(rolling_checksum_pyx_mod.pyx:4:0)
> >> StatListNode.stats[2] = StatListNode(rolling_checksum_pyx_mod.pyx:9:0)
> >> StatListNode.stats[0] = DefNode(rolling_checksum_pyx_mod.pyx:9:0,
> >>     doc = u'Make sure chunk sizes are above and below a pair of
> >> thresholds',
> >>     modifiers = [...]/0,
> >>     name = u'min_max_chunker',
> >>     num_required_args = 1,
> >>     reqd_kw_flags_cname = '0')
> >> Compiler crash traceback from this point on:
> >>   File "Visitor.py", line 173, in
> >> Cython.Compiler.Visitor.TreeVisitor._visitchild
> >> (Cython/Compiler/Visitor.c:3508)
> >>   File
> >>
> "/usr/local/cpython-2.5/lib/python2.5/site-packages/Cython/Compiler/ParseTreeTransforms.py",
> >> line 1380, in visit_FuncDefNode
> >>     for i, yield_expr in enumerate(collector.yields, 1):
> >> TypeError: enumerate() takes exactly 1 argument (2 given)
> >> make: *** [rcms] Error 1
> >>
> >>
> >> The code that produced this is
> >> at http://stromberg.dnsalias.org/svn/backshift/trunk/ - with make
> target
> >> "rcms".  It expects to find a variety of cpython's at
> >> /usr/local/cpython-x.y/bin/python .
> >
> >
> > Oh, and of course, to eliminate some details for you, here's the
> > (automatically generated via m4) file that's giving the compiler error
> > (attached).
> > I suspect this issue may just be because a 2.x-ism (x>5) with how
> enumerate
> > is used has crept into cython.
> > Thanks!
>
>
> Hi!
>
> It seems that you have old python version, 2.4?
>
It's 2.5.


> Here is a fix:
>
> https://github.com/vitek/cython/commit/bb8cd8275bf910117750356845814d4d9d998d6e

Thanks, but...  How do I apply this?  I tried git pull and git clone, but
neither worked for me.  I know SVN pretty well, but I haven't used git much
yet.

-- 
Dan Stromberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20110214/dad04785/attachment-0001.html>


More information about the cython-devel mailing list