Re: newbie list processing question

Stefan Behnel <[email protected]>
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>

Daniel Ashbrook wrote:
> So I've done a lot of Google searching and haven't found an answer to 
> this question, or at least one that I understand.
> 
> I'm trying to write some fairly simple list-processing code using pyrex. 
> As a simple example, let's say I wanted to translate this:
> 
> def addOne(l):
>    assert(isinstance(l, list))
>    for i in xrange(l):
>      l[i] += 1
> 
> or even this:
> 
> def addOne(l):
>    return [i+1 for i in l]
> 
> to fast-running pyrex code. How can I actually access the list properly? 

Take a look at Cython. It supports list comprehensions, so the above just works.

http://cython.org/

Stefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.