[Cython] Regresion in 0.19

2013-05-01 Thread Lisandro Dalcin
See the example below, the last hunk fails with Cython 0.19. It seems
Cython is confusing attribute access with constness.


CYTHON=cython

echo 'cdef import from *:' > defs.pxd
echo 'enum:SIZE'  >> defs.pxd

echo 'from defs cimport *'   > code1.pyx
echo 'cdef char buf[SIZE]'  >> code1.pyx
$CYTHON code1.pyx

echo 'cimport defs'  > code2.pyx
echo 'cdef char buf[defs.SIZE]' >> code2.pyx
$CYTHON code2.pyx


--
Lisandro Dalcin
---
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Regresion in 0.19

2013-05-01 Thread 屈鹏
Why is cython so slow?


2013/5/1 Lisandro Dalcin 

> See the example below, the last hunk fails with Cython 0.19. It seems
> Cython is confusing attribute access with constness.
>
>
> CYTHON=cython
>
> echo 'cdef import from *:' > defs.pxd
> echo 'enum:SIZE'  >> defs.pxd
>
> echo 'from defs cimport *'   > code1.pyx
> echo 'cdef char buf[SIZE]'  >> code1.pyx
> $CYTHON code1.pyx
>
> echo 'cimport defs'  > code2.pyx
> echo 'cdef char buf[defs.SIZE]' >> code2.pyx
> $CYTHON code2.pyx
>
>
> --
> Lisandro Dalcin
> ---
> CIMEC (INTEC/CONICET-UNL)
> Predio CONICET-Santa Fe
> Colectora RN 168 Km 472, Paraje El Pozo
> 3000 Santa Fe, Argentina
> Tel: +54-342-4511594 (ext 1011)
> Tel/Fax: +54-342-4511169
> ___
> cython-devel mailing list
> cython-devel@python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>



-- 
while(sleeping){
++money;
}
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Regresion in 0.19

2013-05-01 Thread Stefan Behnel
屈鹏, 01.05.2013 09:37:
> Why is cython so slow?

This looks like thread-hijacking to me. Maybe you want to elaborate on this
in a new post to the cython-users mailing list.

Stefan

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


Re: [Cython] Regresion in 0.19

2013-05-01 Thread Stefan Behnel
Lisandro Dalcin, 01.05.2013 09:14:
> See the example below, the last hunk fails with Cython 0.19. It seems
> Cython is confusing attribute access with constness.
> 
> 
> CYTHON=cython
> 
> echo 'cdef import from *:' > defs.pxd
> echo 'enum:SIZE'  >> defs.pxd
> 
> echo 'from defs cimport *'   > code1.pyx
> echo 'cdef char buf[SIZE]'  >> code1.pyx
> $CYTHON code1.pyx
> 
> echo 'cimport defs'  > code2.pyx
> echo 'cdef char buf[defs.SIZE]' >> code2.pyx
> $CYTHON code2.pyx

With the above setup, I get Cython compile errors in 0.19:

Error compiling Cython file:

...
cimport defs
cdef char buf[defs.SIZE]
 ^

code2.pyx:2:18: Not allowed in a constant expression

Interesting enough, this happens during declaration analysis, not during
type analysis. Looks like that's needed because the array size is part of
the declaration.

ISTM that the implementation of analyse_const_expression() is wrong. It
doesn't care about the result of analyse_types().

Stefan

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


Re: [Cython] Regresion in 0.19

2013-05-01 Thread Stefan Behnel
Stefan Behnel, 01.05.2013 09:45:
> Lisandro Dalcin, 01.05.2013 09:14:
>> See the example below, the last hunk fails with Cython 0.19. It seems
>> Cython is confusing attribute access with constness.
>>
>>
>> CYTHON=cython
>>
>> echo 'cdef import from *:' > defs.pxd
>> echo 'enum:SIZE'  >> defs.pxd
>>
>> echo 'from defs cimport *'   > code1.pyx
>> echo 'cdef char buf[SIZE]'  >> code1.pyx
>> $CYTHON code1.pyx
>>
>> echo 'cimport defs'  > code2.pyx
>> echo 'cdef char buf[defs.SIZE]' >> code2.pyx
>> $CYTHON code2.pyx
> 
> With the above setup, I get Cython compile errors in 0.19:
> 
> Error compiling Cython file:
> 
> ...
> cimport defs
> cdef char buf[defs.SIZE]
>  ^
> 
> code2.pyx:2:18: Not allowed in a constant expression
> 
> Interesting enough, this happens during declaration analysis, not during
> type analysis. Looks like that's needed because the array size is part of
> the declaration.
> 
> ISTM that the implementation of analyse_const_expression() is wrong. It
> doesn't care about the result of analyse_types().

Yep, an oversight of my analyse_types() refactoring and cleanup.

https://github.com/scoder/cython/commit/db1f0ad5a5ac45d2a1da45211f9d344b4d83cab8

I'll give it a run through Jenkins before pushing it upstream.

Stefan

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


Re: [Cython] Autodoc improvements (#216)

2013-05-01 Thread Stefan Behnel
Nikita Nemkin, 26.04.2013 13:33:
> On Tue, 23 Apr 2013 10:19:15 +0600, Robert Bradshaw wrote:
> 
>> Jumping into this thread late, improvements (1) and (3) certainly seem
>> beneficial. As far as documenting "attributes," I can't see much of a
>> use, but the downsides seem are low enough (accidentally assigning a
>> stray string to the previously declared attribute) and the
>> implementation non-invasive enough that I'm +0.5 for this change. It
>> doesn't introduce new syntax or behavior, just additional semantic
>> meaning for those (otherwise unlikely to occur) strings and sure beats
>> writing them out as properties (though the fact that cdef attributes
>> are properties should be considered more of an implementation detail
>> IMHO).
> 
> I've just found a 4 year old ticket requesting the same feature (2):
> http://trac.cython.org/cython_trac/ticket/206

Just because there's a ticket doesn't mean that it should be fixed, but
I'll give in on this one. Nikita, if you add the test that proves that
newlines prevent a subsequent string from becoming a docstring, i.e. that

cdef attr

"this is not a docstring"

behaves as expected and is different from

cdef attr
"this is a docstring"

I'll merge your pull request.

Stefan

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


Re: [Cython] Autodoc improvements (#216)

2013-05-01 Thread Stefan Behnel
Stefan Behnel, 01.05.2013 11:50:
> Nikita Nemkin, 26.04.2013 13:33:
>> On Tue, 23 Apr 2013 10:19:15 +0600, Robert Bradshaw wrote:
>>
>>> Jumping into this thread late, improvements (1) and (3) certainly seem
>>> beneficial. As far as documenting "attributes," I can't see much of a
>>> use, but the downsides seem are low enough (accidentally assigning a
>>> stray string to the previously declared attribute) and the
>>> implementation non-invasive enough that I'm +0.5 for this change. It
>>> doesn't introduce new syntax or behavior, just additional semantic
>>> meaning for those (otherwise unlikely to occur) strings and sure beats
>>> writing them out as properties (though the fact that cdef attributes
>>> are properties should be considered more of an implementation detail
>>> IMHO).
>>
>> I've just found a 4 year old ticket requesting the same feature (2):
>> http://trac.cython.org/cython_trac/ticket/206
> 
> Just because there's a ticket doesn't mean that it should be fixed, but
> I'll give in on this one. Nikita, if you add the test that proves that
> newlines prevent a subsequent string from becoming a docstring, i.e. that
> 
> cdef attr
> 
> "this is not a docstring"
> 
> behaves as expected and is different from
> 
> cdef attr
> "this is a docstring"
> 
> I'll merge your pull request.

... and I just noticed that you already did that, and also removed the
warning about stray docstrings. Sorry for that. I'll merge it in.

Stefan

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


Re: [Cython] [cython-users] Bug in 0.19 (with example)

2013-05-01 Thread Stefan Behnel
Eric Frederich, 01.05.2013 18:59:
> I have discovered a bug in Cython 0.19
> 
> This code works in 0.15.1 but not in 0.19.
> I haven't tested it anywhere in between.
> 
> The following 3 files are listed at the end of this email.
> blah.h
> blah.pxd
> test.pyx
> 
> The errors I get are the following:
> test.pyx:3:18: Not allowed in a constant expression
> test.pyx:3:18: Array dimension not integer
> test.pyx:3:20: Variable type 'char []' is incomplete
> 
> The line is:
> cdef char[blah.FOO] x
> 
> If I do:
> cdef char[int(blah.FOO)] x
> ... I get the following error:

Thanks for the report. Looks like a known bug, however, already reported
and fixed:

http://mail.python.org/pipermail/cython-devel/2013-May/003631.html

Stefan

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


Re: [Cython] [cython-users] Bug in 0.19 (with example)

2013-05-01 Thread Eric Frederich
Thanks,

Glad to see it was caught.
... and glad that there is a workaround for me at the moment with the +0

~Eric

On Wed, May 1, 2013 at 1:57 PM, Stefan Behnel  wrote:
> Eric Frederich, 01.05.2013 18:59:
>> I have discovered a bug in Cython 0.19
>>
>> This code works in 0.15.1 but not in 0.19.
>> I haven't tested it anywhere in between.
>>
>> The following 3 files are listed at the end of this email.
>> blah.h
>> blah.pxd
>> test.pyx
>>
>> The errors I get are the following:
>> test.pyx:3:18: Not allowed in a constant expression
>> test.pyx:3:18: Array dimension not integer
>> test.pyx:3:20: Variable type 'char []' is incomplete
>>
>> The line is:
>> cdef char[blah.FOO] x
>>
>> If I do:
>> cdef char[int(blah.FOO)] x
>> ... I get the following error:
>
> Thanks for the report. Looks like a known bug, however, already reported
> and fixed:
>
> http://mail.python.org/pipermail/cython-devel/2013-May/003631.html
>
> Stefan
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "cython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to cython-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel