Stefan Behnel | 10 Sep 18:40 2014
Picon

Cython 0.21 released

Hi all,

on behalf of the Cython dev team, I'm pleased to announce the release of
Cython 0.21, a major feature release. Thanks everyone who contributed code,
documentation improvements, test feedback, bug reports and/or otherwise
helpful insights for this release.

I copied the complete changelog of this release below, but here are the
major highlights, in addition to the many bug fixes and general
improvements in this release.

* Legacy code and support for old CPython versions was removed, baselines
are now Python 2.6 and 3.2.

* cdef functions finally support inner Python functions with closures.

* C enums can now be declared as "cpdef" to publish them to Python space.

* Python method calls, boolean "and/or" operators and cascaded assignments
were optimised to streamline calls and type coercions.

* The annotated HTML code output is syntax highlighted and beautified.

Have fun,

Stefan

Downloads:
https://pypi.python.org/pypi/Cython/0.21

(Continue reading)

Marc-Alexandre Côté | 9 Sep 04:05 2014
Picon

Fused types problems with class inheritance

Hi, I am using Cython 0.20.2 on LinuxMint 17 x64.

I created a basic example to reproduce the error:

Does someone encounter this problem before?

--
Marc

--

---
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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Tom Tom | 8 Sep 23:14 2014
Picon

Install Cython into Python3X

Hi,
Can anyone tell me how to install cython on Python 3X series.

Thank you

--

---
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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Stefan Behnel | 8 Sep 22:23 2014
Picon

Cython 0.21 release candidate

Hi all,

I uploaded a release candidate for 0.21. There were a couple of more
changes and cleanups since the last beta, so please give it another quick
round of testing.

http://www.cython.org/release/Cython-0.21rc1.tar.gz

http://www.cython.org/release/Cython-0.21rc1.tar.gz.asc

Complete changelog:

https://github.com/cython/cython/blob/8337b8aec2ecbb4480d551e12b1faf9b21ba2cb1/CHANGES.rst

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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joshua Landau | 8 Sep 13:54 2014

Suggested addition to the docs on memory allocation

I have this Stack Overflow post:

http://stackoverflow.com/a/21054369/1763356

People seem to find it useful and I recently got a comment saying that
this should be in the docs. Thus, I'm raising the idea here. It might
make sense to just have a link, but you could also properly integrate
it if you have an appropriate place. One advantage of a link is that I
can keep it up to date (you can, too, being on Stack Overflow).

--

-- 

--- 
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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nathan Goldbaum | 4 Sep 22:05 2014
Picon

cython.parallel.prange num_threads keyword argument must be a constant

I have the following test code:

    from cython import parallel

    def test_function(num_threads=4):
        cdef int i

        with nogil:
            for i in parallel.prange(10, num_threads=num_threads):
                pass

When I cythonize and compile this, I get the following error from gcc 4.4.6:

    [goldbaum <at> eudora cython_test]$ python setup.py install
    running install
    running build
    running build_ext
    cythoning test.pyx to test.c
    building 'test' extension
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/pfs/goldbaum/anaconda/include/python2.7 -c test.c -o build/temp.linux-x86_64-2.7/test.o -fopenmp
    test.c: In function ‘__pyx_pf_4test_test_function’:
    test.c:765: error: expected integer expression before end of line
    error: command 'gcc' failed with exit status 1

The autogenerated c near line 765 looks like this:

 761            __pyx_t_2 = (10 - 0) / 1;
 762            if (__pyx_t_2 > 0)
 763            {
 764                #ifdef _OPENMP
 765                #pragma omp parallel num_threads(__pyx_v_num_threads)
 766                #endif /* _OPENMP */
 767                {
 768                    #ifdef _OPENMP
 769                    #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i)


If I change the argument of the num_threads keyword argument to a constant, it builds and runs correctly.

I'm not sure whether this is a bug, a misunderstanding on my part, or simply an undocumented caveat of the way prange is transpiled to openmp pragmas. Optimally I'd like to be able to control the number of threads used in the prange from python.

Best,

Nathan Goldbaum

--

---
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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lars Bittrich | 4 Sep 20:38 2014
Picon

Segmentation Fault due to reference counting problem with typed memory views and ternary operators

Hi all,

I believe that I stumbled upon a bug with typed memory views in conjunction with ternary operators. A small reduced example follows:

# example.pyx
cdef localviewtest(double[:] cview1, double[:] cview2, int i):
   cdef int j
   cdef double[:] cviewlocal
   # no crash with
   #if i==0:
   #    cviewlocal = cview1
   #else:
   #    cviewlocal = cview2
   # crash on exit of localviewtest in __PYX_XDEC_MEMVIEW
   cviewlocal = cview1 if i==0 else cview2
   for j in range(cviewlocal.shape[0]):
       print cviewlocal[j]

def test(int i):
   cdef double c[2]
   cdef double b[2]
   c[0] = 1.0
   c[1] = 2.0
   b[0] = 3.0
   b[1] = 4.0
   localviewtest(c, b, i)

In Ipython the example crashes:
In [1]: import pyximport; pyximport.install()
In [2]: import example
In [3]: example.test(0)
1.0
2.0
Fatal Python error: Acquisition count is 0 (line 1614)

I tested this on Windows with cython 0.20.2 and on Ubuntu cython 0.20.1post0. The use of the ternary operator seems to cause the problem. If this is hard fix maybe a hint in the documentation would be nice, as this problem is really hard to track down.

Thanks,
Lars

--

---
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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ivan Smirnov | 1 Sep 14:37 2014
Picon

cdef extern packed struct?

Wonder what's the correct course of action if I have a packed structure defined in C++ world and it needs to be used in Cython:

#pragma pack(push, 1)
typedef struct Foo {
    int32_t a
;
   
char s[10];
    uint16_t b
;
} Foo;
#pragma pack(pop)

Since "packed" qualifier is not permitted inside extern blocks, would Cython be able to figure out that the structure is packed?

cdef extern from "foo.h":
    ctypedef
struct Foo:
        int32_t a
       
char[10] s
        uint16_t b

It seems to work on simplest examples, is there any catch?

--

---
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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Pierre Carbonnelle | 31 Aug 11:58 2014
Picon

how to have hashable extension types in pure python mode ? (__eq__ error)

Hi,

I'm in the process of converting a pure python library to Cython to obtain speed gains, and it looks promising.  Because it is distributed on pypi, it needs to work in as many environments as possible (currently 2.7, 3+ and pypy).  To allow for Windows users without C compilers, I plan to use Cython in pure python mode, with all Cython declarations in a augmenting .pxd file.

I need to convert one class to a cdef extension type, but it is hashable (__hash__), and thus needs a __eq__ method in CPython 3.  Unfortunately, Cython raises an error :

Special method __eq__ must be implemented via __richcmp_


I did implement an extra __richcmp__ method, but it still raises this error.  Using __cmp__ instead would work on Python 2.7, but not 3+.

I found a recent discussion on this forum, leading to bug 130, but it's 6 years old, and demoted to 'wishlist'.  

Is there a solution in pure python mode with pxd file ?  (or Via cython decorators, but  I'm afraid I would lose readability).

Wouldn't it be possible for Cython to ignore this error when a richcmp method is defined ?

Thanks in advance.
Pierre C.

--

---
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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Martin Bammer | 30 Aug 17:55 2014
Picon

Syntax error in simple statement list when trying to annotate file

What is wrong here:

cpdef unsigned int get_typesize(unicode dtype):
    return { u"BYTE" : 1, u"UBYTE" : 1, u"SBYTE" : 1, u"PBYTE" : 1, u"WORD" : 2, u"UWORD" : 2, u"SWORD" : 2, u"PWORD" : 2,
             u"LONG" : 4, u"ULONG" : 4, u"SLONG" : 4, u"PLONG" : 4,
             u"FLOAT32_IEEE" : 4, u"FLOAT64_IEEE" : 8, u"A_INT64" : 8, u"A_UINT64" : 8 }[dtype]

Fails when I call cython with option "-a". Without the option "-a" the file compiles without errors.


--

---
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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matthew Johnson | 29 Aug 15:02 2014
Picon

redefinition error creating C++ vectors of typed memoryviews

I'm getting a compilation error that I think might be a bug.

I'm trying to make C++ vectors of typed memoryviews like

    cdef vector[double[:]] v = some_list

It seems to work fine when I only have one such line, but when there are two lines (i.e. two such vectors being created) I get a redefinition error:
    
    error: redefinition of 'std::vector<__Pyx_memviewslice> __pyx_convert_vector_from_py___Pyx_memviewslice(PyObject*)'

Here is a minimal example: https://gist.github.com/mattjj/15f28177d68238659386

The error does not happen if we instead try to create two vector[int] types or one vector[double[:]] and one vector[int].

This might be the same error as with https://groups.google.com/forum/#!topic/cython-users/NMfMmNkBp9w but my minimal example is much smaller!

Should I submit this as a bug?

--

---
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+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gmane