[Cython] Two generators in one function

2013-02-04 Thread David Roe
Hi everyone,
I ran into the following problem using Cython 0.17.4 (current version of
Sage).

If you try to compile a file with the following function in it:

def test_double_gen(L):
a = all(x != 0 for x in L)
b = all(x != 1 for x in L)
return a and b

you get errors from the Cython compiler about 'genexpr' being redefined.

Error compiling Cython file:

...


def test_double_gen(L):
a = all(x != 0 for x in L)
b = all(x != 1 for x in L)
 ^


cython_test.pyx:5:14: 'genexpr' already declared

Error compiling Cython file:

...


def test_double_gen(L):
a = all(x != 0 for x in L)
 ^


cython_test.pyx:4:14: Previous declaration is here

Error compiling Cython file:

...


def test_double_gen(L):
a = all(x != 0 for x in L)
b = all(x != 1 for x in L)
 ^


cython_test.pyx:5:14: 'genexpr' redeclared

Are you currently only able to use one inline generator pre function?
David
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Two generators in one function

2013-02-13 Thread David Roe
Thanks.
David


On Wed, Feb 13, 2013 at 10:29 PM, Robert Bradshaw wrote:

> This is due to the archaic --disable-function-redefinition flag.
>
> On Mon, Feb 4, 2013 at 4:28 PM, David Roe  wrote:
> > Hi everyone,
> > I ran into the following problem using Cython 0.17.4 (current version of
> > Sage).
> >
> > If you try to compile a file with the following function in it:
> >
> > def test_double_gen(L):
> > a = all(x != 0 for x in L)
> > b = all(x != 1 for x in L)
> > return a and b
> >
> > you get errors from the Cython compiler about 'genexpr' being redefined.
> >
> > Error compiling Cython file:
> > 
> > ...
> >
> >
> > def test_double_gen(L):
> > a = all(x != 0 for x in L)
> > b = all(x != 1 for x in L)
> >  ^
> > 
> >
> > cython_test.pyx:5:14: 'genexpr' already declared
> >
> > Error compiling Cython file:
> > 
> > ...
> >
> >
> > def test_double_gen(L):
> > a = all(x != 0 for x in L)
> >  ^
> > 
> >
> > cython_test.pyx:4:14: Previous declaration is here
> >
> > Error compiling Cython file:
> > 
> > ...
> >
> >
> > def test_double_gen(L):
> > a = all(x != 0 for x in L)
> > b = all(x != 1 for x in L)
> >  ^
> > 
> >
> > cython_test.pyx:5:14: 'genexpr' redeclared
> >
> > Are you currently only able to use one inline generator pre function?
> > David
> >
> >
> > ___
> > cython-devel mailing list
> > cython-devel@python.org
> > http://mail.python.org/mailman/listinfo/cython-devel
> >
> ___
> cython-devel mailing list
> cython-devel@python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] [cython-users] freelist benchmarks

2013-02-24 Thread David Roe
I changed the current type pointer check to look at tp_basicsize instead.

> That made it work for almost all classes in lxml's own Element hierarchy,
> with only a couple of exceptions in lxml.objectify that have one additional
> object field. So, just extending the freelist support to use two different
> lists for different struct sizes instead of just one would make it work for
> all of lxml already. Taking a look at Sage to see how the situation appears
> over there would be interesting, I guess.
>

I found some chains of length 5.  This could be shortened to 4 by putting
the freelist at the level of Element (which is where you most care about
speed of object creation).

SageObject
-> Element (_parent attribute and cdef methods)
-> Vector (_degree)
-> FreeModuleElement (_is_mutable)
-> FreeModuleElement_generic_dense (_entries)

SageObject
-> Element (_parent attribute and cdef methods)
->sage.structure.element.Matrix (_nrows)
-> sage.matrix.matrix.Matrix (_base_ring)
-> Matrix_integer_dense (_entries)

This does look cool to have though.
David
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Cython 0.26 release

2017-06-23 Thread David Roe
On Wed, Jun 21, 2017 at 12:41 PM, Jeroen Demeyer 
wrote:

> On 2017-06-21 20:25, Robert Bradshaw wrote:
>
>> I suppose in that case we just got lucky that no one cimported these
>> classes and tried to use methods after this point in the vtable...
>>
>
> I think that's the case indeed.


In fact, Julian Rueth and I eventually did cimport one of these classes
(Polynomial_generic_dense), eventually leading to
https://github.com/cython/cython/issues/1732.

A warning does seem like it would make fixing existing code easier.
David

>
>
> ___
> cython-devel mailing list
> cython-devel@python.org
> https://mail.python.org/mailman/listinfo/cython-devel
>
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel