orson peters | 1 Apr 01:00 2012
Picon

Possible to make cdef classes behave as regular ones?

Is it possible to make cdef classes have all the properties regular
classes have (most importantly assigning arbitrary elements)?

If not, perhaps it can be added in pretty much the same way like weak
referencing (with a field that has to be explicitly defined)?

Robert Bradshaw | 1 Apr 01:49 2012
Picon

Re: Possible to make cdef classes behave as regular ones?

On Sat, Mar 31, 2012 at 4:00 PM, orson peters <spionman007 <at> gmail.com> wrote:
> Is it possible to make cdef classes have all the properties regular
> classes have (most importantly assigning arbitrary elements)?
>
> If not, perhaps it can be added in pretty much the same way like weak
> referencing (with a field that has to be explicitly defined)?

Not currently, but you can make a regular class (even in your pyx
file) that inherits from a cdef class, which may be a sufficient
stopgap.

- Robert

Stefan Behnel | 1 Apr 07:06 2012
Picon

Re: Possible to make cdef classes behave as regular ones?

Robert Bradshaw, 01.04.2012 01:49:
> On Sat, Mar 31, 2012 at 4:00 PM, orson peters wrote:
>> Is it possible to make cdef classes have all the properties regular
>> classes have (most importantly assigning arbitrary elements)?
>>
>> If not, perhaps it can be added in pretty much the same way like weak
>> referencing (with a field that has to be explicitly defined)?
> 
> Not currently

And this is a rather long standing feature request.

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

CC'ing Lisandro here because he originally had a patch for it that may be a
good start.

Stefan

Vitja Makarov | 1 Apr 08:57 2012
Picon

Re: Cython 0.16 Release Candidate

2012/4/1 Olivier Grisel <olivier.grisel <at> ensta.org>:
> Le 31 mars 2012 22:59, mark florisson <markflorisson88 <at> gmail.com> a écrit :
>> We are happy to announce the first release candidate for Cython 0.16,
>> you can grab it from here: http://wiki.cython.org/ReleaseNotes-0.16
>>
>> Since the beta last month several issues have been fixed, including
>> the NumPy array attribute access deprecation, which are now rewritten
>> to use the NumPy macros. Another serious bug in the reversed(range())
>> optimization was disabled, a C compiler bug on OS X Lion in OpenMP
>> code was circumvented, the documentation for fused types has been
>> improved, some bugs related to fused C++ and buffers types have been
>> fixed, and nogil was added to the included STL declarations.
>>
>> I encourage everyone to give it a try, see if your project still
>> compiles and works, and if it doesn't to take up those torches and
>> pitchforks from your desks, you know where to find us.
>
> Here is a pitchfork:
>
>  https://gist.github.com/2268824
>
> This is a crash report when trying to cython-ify scikit-learn master
> with both master and the 0.16rc0 tag of the cython repo.
>

This may be related to this issue:

https://github.com/cython/cython/commit/3dc1d68b6ccf437df0bce0bd18bf1862ff49a440

It's better to cherry-pick this commit.
(Continue reading)

Vitja Makarov | 1 Apr 09:06 2012
Picon

Re: Cython 0.16 Release Candidate

2012/4/1 Vitja Makarov <vitja.makarov <at> gmail.com>:
> 2012/4/1 Olivier Grisel <olivier.grisel <at> ensta.org>:
>> Le 31 mars 2012 22:59, mark florisson <markflorisson88 <at> gmail.com> a écrit :
>>> We are happy to announce the first release candidate for Cython 0.16,
>>> you can grab it from here: http://wiki.cython.org/ReleaseNotes-0.16
>>>
>>> Since the beta last month several issues have been fixed, including
>>> the NumPy array attribute access deprecation, which are now rewritten
>>> to use the NumPy macros. Another serious bug in the reversed(range())
>>> optimization was disabled, a C compiler bug on OS X Lion in OpenMP
>>> code was circumvented, the documentation for fused types has been
>>> improved, some bugs related to fused C++ and buffers types have been
>>> fixed, and nogil was added to the included STL declarations.
>>>
>>> I encourage everyone to give it a try, see if your project still
>>> compiles and works, and if it doesn't to take up those torches and
>>> pitchforks from your desks, you know where to find us.
>>
>> Here is a pitchfork:
>>
>>  https://gist.github.com/2268824
>>
>> This is a crash report when trying to cython-ify scikit-learn master
>> with both master and the 0.16rc0 tag of the cython repo.
>>
>
> This may be related to this issue:
>
> https://github.com/cython/cython/commit/3dc1d68b6ccf437df0bce0bd18bf1862ff49a440
>
(Continue reading)

Justin | 1 Apr 18:28 2012
Picon

Re: Error compiling cython with numpy arrays

Yes, I've always been in the habit of importing numpy as nu.

I've written another program just to see which aspects of cython are
working and which aren't, so I can just show that source here.

The original had no problems other than the type declarations, it
compiled once I removed any ndarray type declarations, but I'm
concerned about speed losses since my algorithm has a lot of looping
over the arrays.

Basically, I've written the following useless program to test
compilation and execution speed:

import numpy as nu
cimport numpy as nu

from libc.math cimport sqrt
cdef double sqrt(double x):
    return sqrt(x)

#cdef nu.ndarray[nu.float,ndim=1] start=nu.zeros(10000)
#cdef nu.ndarray start=nu.zeros(10000,dtype=nu.float)
start=nu.zeros(10000,dtype=nu.float)

def run_test(int n_loops):
    global start
    cdef:
        nu.ndarray arr=nu.zeros(len(start),dtype=nu.float)
        nu.float_t add=0.0
        int i, j, l
(Continue reading)

Al Danial | 1 Apr 19:00 2012
Picon

Re: Cython 0.16 Release Candidate

We are happy to announce the first release candidate for Cython 0.16,
you can grab it from here: http://wiki.cython.org/ReleaseNotes-0.16
...
I encourage everyone to give it a try, see if your project still
compiles and works, and if it doesn't to take up those torches and
pitchforks from your desks, you know where to find us.

Hello.  I have code that builds with 0.15.1, but fails with "Cannot convert 'PyObject *' to Python object" using 0.16rc0.  My system is x86_64 Fedora 14 if that matters. To reproduce the problem:


 cd pynastran-read-only/cython/

 make
 
 -- Al
Stefan Behnel | 1 Apr 19:23 2012
Picon

Re: Cython 0.16 Release Candidate

Al Danial, 01.04.2012 19:00:
>> We are happy to announce the first release candidate for Cython 0.16,
>> you can grab it from here: http://wiki.cython.org/ReleaseNotes-0.16
>> ...
>> I encourage everyone to give it a try, see if your project still
>> compiles and works, and if it doesn't to take up those torches and
>> pitchforks from your desks, you know where to find us.
>>
> 
> Hello.  I have code that builds with 0.15.1, but fails with "Cannot convert
> 'PyObject *' to Python object" using 0.16rc0.  My system is x86_64 Fedora
> 14 if that matters. To reproduce the problem:
> 
>  svn checkout http://pynastran.googlecode.com/svn/trunk/pyNastran/op4pynastran-read-only

Thanks for the report. I'm getting a 404 on the URL above when I open it in
my browser - didn't try the checkout yet. In any case, could you paste the
exact error message that Cython gives you, including the name and line
number of the source file that you are compiling?

Stefan

Stefan Behnel | 1 Apr 19:37 2012
Picon

Re: Re: Error compiling cython with numpy arrays

Justin, 01.04.2012 18:28:
> from libc.math cimport sqrt
> cdef double sqrt(double x):
>     return sqrt(x)

What is this even supposed to do? When I compile it, I get a compile error:

Error compiling Cython file:
------------------------------------------------------------
...
from libc.math cimport sqrt
cdef double sqrt(double x):
    ^
------------------------------------------------------------
sq.pyx:2:5: Function signature does not match previous declaration

(and I'm quite happy to get one at all, even if it's not exactly the one
I'd like to get)

Stefan

Al Danial | 1 Apr 21:02 2012

Re: Cython 0.16 Release Candidate

> Hello.  I have code that builds with 0.15.1, but fails with "Cannot convert
> 'PyObject *' to Python object" using 0.16rc0.  My system is x86_64 Fedora
> 14 if that matters. To reproduce the problem:
>
>  svn checkout http://pynastran.googlecode.com/svn/trunk/pyNastran/op4pynastran-read-only

Thanks for the report. I'm getting a 404 on the URL above when I open it in
my browser - didn't try the checkout yet. In any case, could you paste the
exact error message that Cython gives you, including the name and line
number of the source file that you are compiling?

The project URL is http://code.google.com/p/pynastran/ -- but only a small
portion of the code is related to the Cython 0.16rc0 issue.  The URL from 
my earlier email only works with "svn co".

No matter; I've attached tar files of the source in question and the output
from make using 0.15.1 and 0.16rc0.  (When you expand the source tar file,
you'll need to "cd pynastran-read-only/cython" otherwise you'll build
in the wrong location.)        -- Al

Attachment (pynastran_op4.tar.bz2): application/x-bzip2, 54 KiB
Attachment (make_results.tar.bz2): application/x-bzip2, 2966 bytes

Gmane