Cython alpha 0.24

167 views
Skip to first unread message

Robert Bradshaw

unread,
Mar 11, 2016, 3:24:26 AM3/11/16
to cython...@googlegroups.com, Core developer mailing list of the Cython compiler
We are getting ready to push a new major release. A first alpha is up
at http://cython.org/release/Cython-0.24a0.tar.gz

To avoid surprises, please test and report.

Thanks,
Robert

Jeroen Demeyer

unread,
Mar 11, 2016, 5:24:38 AM3/11/16
to cython...@googlegroups.com
Compiling Sage fails:

[ 27/442] Cythonizing sage/matrix/matrix_double_dense.pyx
Traceback (most recent call last):
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Build/Dependencies.py",
line 1052, in cythonize_one_helper
return cythonize_one(*m)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Build/Dependencies.py",
line 1017, in cythonize_one
result = compile([pyx_file], options)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py",
line 684, in compile
return compile_multiple(source, options)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py",
line 662, in compile_multiple
result = run_pipeline(source, options, context=context)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py",
line 492, in run_pipeline
err, enddata = Pipeline.run_pipeline(pipeline, source)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Pipeline.py",
line 365, in run_pipeline
data = phase(data)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Pipeline.py",
line 53, in generate_pyx_code_stage
module_node.process_implementation(options, result)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ModuleNode.py",
line 129, in process_implementation
self.generate_c_code(env, options, result)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ModuleNode.py",
line 357, in generate_c_code
self.body.generate_function_definitions(env, code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 436, in generate_function_definitions
stat.generate_function_definitions(env, code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 436, in generate_function_definitions
stat.generate_function_definitions(env, code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 4657, in generate_function_definitions
self.body.generate_function_definitions(self.scope, code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 436, in generate_function_definitions
stat.generate_function_definitions(env, code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 3076, in generate_function_definitions
FuncDefNode.generate_function_definitions(self, env, code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 1943, in generate_function_definitions
self.generate_function_body(env, code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 1699, in generate_function_body
self.body.generate_execution_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 442, in generate_execution_code
stat.generate_execution_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 4807, in generate_execution_code
self.generate_rhs_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 5094, in generate_rhs_evaluation_code
self.rhs.generate_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 7463, in generate_evaluation_code
generate_inner_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 705, in generate_evaluation_code
self.generate_result_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 7537, in generate_result_code
self.generate_operation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 7553, in generate_operation_code
self.loop.generate_execution_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/Nodes.py",
line 6217, in generate_execution_code
self.iterator.generate_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 699, in generate_evaluation_code
self.generate_subexpr_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 714, in generate_subexpr_evaluation_code
node.generate_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 699, in generate_evaluation_code
self.generate_subexpr_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 714, in generate_subexpr_evaluation_code
node.generate_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 699, in generate_evaluation_code
self.generate_subexpr_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 714, in generate_subexpr_evaluation_code
node.generate_evaluation_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 705, in generate_evaluation_code
self.generate_result_code(code)
File
"/usr/local/src/sage-git/local/lib/python2.7/site-packages/Cython-0.24a0-py2.7-linux-x86_64.egg/Cython/Compiler/ExprNodes.py",
line 12225, in generate_result_code
self.arg.type.to_py_call_code(
AttributeError: 'ErrorType' object has no attribute 'to_py_call_code'

Jeroen Demeyer

unread,
Mar 11, 2016, 6:34:19 AM3/11/16
to cython...@googlegroups.com
On 2016-03-11 11:24, Jeroen Demeyer wrote:
> Compiling Sage fails:

Bisection:

767fce81073e7f96c6e9dc95906d96795e61cc32 is the first bad commit
commit 767fce81073e7f96c6e9dc95906d96795e61cc32
Author: Robert Bradshaw <robe...@gmail.com>
Date: Sun Feb 21 01:39:29 2016 -0800

Allow default template parameters for C++ classes.

This is done with the T=* syntax, similar to default args
of cdef methods.

This does, however, expose us to types that we can't
explicitly declare.

Jeroen Demeyer

unread,
Mar 11, 2016, 2:03:40 PM3/11/16
to cython...@googlegroups.com
Minimized failing source file:


class foo(object):
def meth(self):
a = min(self.x, self.y)
return a

Kevin Thornton

unread,
Mar 11, 2016, 6:53:48 PM3/11/16
to Core developer mailing list of the Cython compiler, cython...@googlegroups.com
Hi,

I just built a large project with the alpha version.  All looks good.  The only new/odd thing is a lot of warnings of this flavor:

warning: View.MemoryView:219:4: 'property memview:' syntax is deprecated, use '@property'
warning: View.MemoryView:536:4: 'property T:' syntax is deprecated, use '@property'
warning: View.MemoryView:543:4: 'property base:' syntax is deprecated, use '@property'
warning: View.MemoryView:548:4: 'property shape:' syntax is deprecated, use '@property'
warning: View.MemoryView:553:4: 'property strides:' syntax is deprecated, use '@property'
warning: View.MemoryView:562:4: 'property suboffsets:' syntax is deprecated, use '@property'
warning: View.MemoryView:570:4: 'property ndim:' syntax is deprecated, use '@property'
warning: View.MemoryView:575:4: 'property itemsize:' syntax is deprecated, use '@property'
warning: View.MemoryView:580:4: 'property nbytes:' syntax is deprecated, use '@property'
warning: View.MemoryView:585:4: 'property size:' syntax is deprecated, use '@property'
warning: View.MemoryView:984:4: 'property base:' syntax is deprecated, use '@property'
warning: View.MemoryView:219:4: 'property memview:' syntax is deprecated, use '@property'
warning: View.MemoryView:536:4: 'property T:' syntax is deprecated, use '@property'
warning: View.MemoryView:543:4: 'property base:' syntax is deprecated, use '@property'
warning: View.MemoryView:548:4: 'property shape:' syntax is deprecated, use '@property'
warning: View.MemoryView:553:4: 'property strides:' syntax is deprecated, use '@property'
warning: View.MemoryView:562:4: 'property suboffsets:' syntax is deprecated, use '@property'
warning: View.MemoryView:570:4: 'property ndim:' syntax is deprecated, use '@property'
warning: View.MemoryView:575:4: 'property itemsize:' syntax is deprecated, use '@property'
warning: View.MemoryView:580:4: 'property nbytes:' syntax is deprecated, use '@property'

--Kevin
_______________________________________________
cython-devel mailing list
cython...@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Robert Bradshaw

unread,
Mar 13, 2016, 9:00:38 AM3/13/16
to cython...@googlegroups.com
Thanks! I'll try to get a fix out.
> --
>
> --- 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...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Robert Bradshaw

unread,
Mar 13, 2016, 9:01:15 AM3/13/16
to cython...@googlegroups.com
Oh, yes, we should fix our own code :).

> --Kevin
> On Fri, Mar 11, 2016 at 12:26 AM Robert Bradshaw <robe...@gmail.com> wrote:
>>
>> We are getting ready to push a new major release. A first alpha is up
>> at http://cython.org/release/Cython-0.24a0.tar.gz
>>
>> To avoid surprises, please test and report.
>>
>> Thanks,
>> Robert
>> _______________________________________________
>> cython-devel mailing list
>> cython...@python.org
>> https://mail.python.org/mailman/listinfo/cython-devel
>

Robert Bradshaw

unread,
Mar 17, 2016, 1:10:43 PM3/17/16
to cython...@googlegroups.com
On Fri, Mar 11, 2016 at 11:03 AM, Jeroen Demeyer <jdem...@cage.ugent.be> wrote:
Thanks, that was very helpful. New tarball at
http://cython.org/release/Cython-0.24a1.tar.gz (Also includes cleanup
of the property warnings.)

Björn Dahlgren

unread,
Mar 18, 2016, 9:23:08 AM3/18/16
to cython-users

On Thursday, 17 March 2016 18:10:43 UTC+1, Robert Bradshaw wrote: 
Thanks, that was very helpful. New tarball at
http://cython.org/release/Cython-0.24a1.tar.gz (Also includes cleanup
of the property warnings.)

Just tried this with one of my packages. Everything works fine (tests pass).
I do get the deprecation warning (from my own code using `property x:` syntax).
Since what version of Cython is @property supported?
The docs seem still to only show the old syntax:  https://github.com/cython/cython/blob/master/docs/src/userguide/extension_types.rst#properties

Joshua

unread,
Mar 18, 2016, 11:55:15 AM3/18/16
to cython-users, cython...@python.org
I ran across a compilation error using 0.24a1. It's actually the same error that I posted to the list a while back (https://groups.google.com/d/msg/cython-users/_ShPVfZAuKA/RxiS0dfRDwAJ), but at the time, I didn't have a minimal working example that had been extracted from a much more complicated project that I couldn't post publicly. 

I now have a minimal demonstration that I've posted here:

It fails on both OSX and Windows (using mingw) with traceback:

$ python setup.py build_ext -i
Compiling factors.pyx because it changed.
Compiling xlib.pyx because it changed.
[1/2] Cythonizing factors.pyx
[2/2] Cythonizing xlib.pyx
running build_ext
building
'factors' extension
creating build
creating build
/temp.macosx-10.5-x86_64-2.7
gcc
-fno-strict-aliasing -I/Users/lev/anaconda/envs/test-cython/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I/Users/lev/anaconda/envs/test-cython/lib/python2.7/site-packages/numpy/core/include -I/Users/lev/anaconda/envs/test-cython/include/python2.7 -c factors.c -o build/temp.macosx-10.5-x86_64-2.7/factors.o -O3 -w
gcc
-bundle -undefined dynamic_lookup -L/Users/lev/anaconda/envs/test-cython/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/factors.o -L/Users/lev/anaconda/envs/test-cython/lib -o /Users/lev/Desktop/av4tmp/cython-test/factors.so
building
'xlib' extension
gcc
-fno-strict-aliasing -I/Users/lev/anaconda/envs/test-cython/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I/Users/lev/anaconda/envs/test-cython/lib/python2.7/site-packages/numpy/core/include -I/Users/lev/anaconda/envs/test-cython/include/python2.7 -c xlib.c -o build/temp.macosx-10.5-x86_64-2.7/xlib.o -O3 -w
xlib
.c:17371:63: error: too few arguments to function call, expected 3, have 1
    __pyx_v_7factors_xarr0
= __Pyx_carray_from_py_xarr__type(o); if (PyErr_Occurred()) __PYX_ERR(1, 13, __pyx_L2_error);
                             
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
xlib
.c:4726:1: note: '__Pyx_carray_from_py_xarr__type' declared here
static int __Pyx_carray_from_py_xarr__type(PyObject *__pyx_v_o, struct __pyx_t_15data_structures_xarr_type *__py...
^
xlib
.c:20424:13: error: static declaration of '__Pyx_BufFmt_Init' follows non-static declaration
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
           
^
xlib
.c:20295:9: note: previous implicit declaration is here
        __Pyx_BufFmt_Init
(&ctx, stack, dtype);
       
^
xlib
.c:20789:20: error: static declaration of '__Pyx_BufFmt_CheckString' follows non-static declaration
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
                   
^
xlib
.c:20296:14: note: previous implicit declaration is here
       
if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
             
^
3 errors generated.
error
: command 'gcc' failed with exit status 1

It fails similarly with Cython 0.23.4. It compiles without error using Cython 0.22.1, which is what I'm using in production. 

It looks like a possible codegen error to me since the function call doesn't match the prototype, but it's deep enough in the cython internals that I'll defer to a Cython developer.

Any help with this would be very much appreciated.

Thanks,
Josh
 

Jeroen Demeyer

unread,
Mar 18, 2016, 1:07:27 PM3/18/16
to cython...@googlegroups.com
On 2016-03-17 18:10, Robert Bradshaw wrote:
> New tarball at
> http://cython.org/release/Cython-0.24a1.tar.gz

Works fine in Sage.

Ian Henriksen

unread,
Mar 20, 2016, 2:00:08 AM3/20/16
to cython...@googlegroups.com
Aside from the warnings others already mentioned, DyND's Python bindings are working fine on Windows, OSX, and Linux.
Thanks!
-Ian Henriksen
 

Martin Bammer

unread,
Mar 21, 2016, 7:49:59 PM3/21/16
to cython-users, cython...@python.org
Hi,

there seems to be a bug in the current master when using pxd-files:

test.py:


class A(object):

    def foo(self, a = False, b = True, c = True):
        pass

    def bar(self):
        self.foo(b = False)


test.pxd:


cdef class A:

    cdef foo(self, a = *, b = *, c = *)

    cdef bar(self)


Cythonizing fails with following error:

Error compiling Cython file:
------------------------------------------------------------
...

    def foo(self, a = False, b = True, c = True):
        pass

    def bar(self):
        self.foo(b = False)
               ^
------------------------------------------------------------

cytest.py:8:16: C function call is missing argument 'a'

It seems that cython requests all keyword arguments before the last one which was used in the call.

Regards,

Martin

Martin Bammer

unread,
Mar 21, 2016, 8:27:01 PM3/21/16
to cython-users, cython...@python.org
Hi,

it would be very helpful if the cython compiler crashes would output some more information in some cases but only the traceback.
In my case I had a typo in the pxd file for a keyword arg. The cython compiler crashes and outputs the traceback. With the traceback only the developer has no information why cython is crashing.

For the above case following change in PyrexTypes (line 2900) would be helpful:

def opt_arg_cname(self, arg_name):
try:
return self.op_arg_struct.base_type.scope.lookup(arg_name).cname
except:
print("arg_name=", arg_name)
raise


Regards,

Martin

Martin Bammer

unread,
Mar 21, 2016, 8:29:19 PM3/21/16
to cython-users, cython...@python.org
Hi,

I just saw that PyrexTypes.py seems to have a typo in lines 3740 and 3742:

def __cmp__(self, other):
if isinstance(other, TemplatePlaceholderType):
return cmp(self.name, other.name)
else:
return cmp(type(self), type(other))


PyCharm is complaining that "cmp" is an unresolved reference.

Regards,

Martin


Ian Henriksen

unread,
Mar 21, 2016, 10:06:28 PM3/21/16
to cython...@googlegroups.com, cython...@python.org
AFAICT, that whole function isn't really necessary. It defines the behavior
for when you call `cmp` on an instance of that particular class. In Python
3 that particular builtin function doesn't exist. It'll work fine in Python 2, but
since the codebase supports both it's not clear when that would actually
be useful.
Best,
-Ian Henriksen

Martin Bammer

unread,
Mar 24, 2016, 2:21:17 PM3/24/16
to cython-users, cython...@python.org
Hi,

latest master fails to build with following error:
C:\temp\cython-master\Cython\Plex\Scanners.c(2922) : error C2065: 'op' : undeclared identifier
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

It seems that the macro __Pyx_PyUnicode_IS_TRUE is not correctly defined:

#define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(op)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))

Shouldn't it be:

#define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))


Regards,

Martin

Stefan Behnel

unread,
Mar 24, 2016, 4:05:14 PM3/24/16
to cython...@googlegroups.com
Yes. Already fixed.

Stefan

Martin Bammer

unread,
Mar 24, 2016, 4:20:38 PM3/24/16
to cython-users, cython...@python.org
And what about the define in Scanners.c? It has the same bug.

Regards, Martin

Stefan Behnel

unread,
Mar 24, 2016, 4:32:26 PM3/24/16
to cython...@googlegroups.com
Martin Bammer schrieb am 24.03.2016 um 21:20:
> And what about the define in Scanners.c? It has the same bug.

That's a generated file. You have to delete it manually, though, because
changes in Cython will not trigger a rebuild for all generated files. Just
delete all ".c" files in Cython/Compiler/ and Cython/Plex/.

Sorry for the inconvenience.

Stefan

Robert Bradshaw

unread,
Mar 24, 2016, 5:34:27 PM3/24/16
to cython...@googlegroups.com
keyword arguments in cdef functions are merely syntactic sugar--we
still pass them around as positional C arguments and so can only be
emitted at the end.

Robert Bradshaw

unread,
Mar 24, 2016, 5:41:55 PM3/24/16
to cython...@googlegroups.com
Could you repeat what you mean by "the above case?" There's a lot of
snippets flying around here...

Martin Bammer

unread,
Mar 25, 2016, 1:00:49 PM3/25/16
to cython-users, cython...@python.org
In the following case, in the pxd file there is a typo "tris" instead of "tries", the cython compiler crashes with a traceback but without any helpful information what went wrong:

test.py:


class A(object):

    def foo(self, a, tries = 3):
        pass


test.pxd:


cdef class A:

    cdef foo(self, a, tris = *)

Regards, Martin

Reply all
Reply to author
Forward
0 new messages