[Cython] In-place division in memoryview, ndarray causes compiler error

Matthew Brett matthew.brett at gmail.com
Wed Aug 15 20:38:23 CEST 2012


Hi,

For this file:

<file1>
def div1(int[:] A):
    A[0] /= 1
</file1>

or this one:

<file2>
def div2(object[int, ndim=1] A):
    A[0] /= 1
</file2>

I get:

  File "/Users/mb312/usr/local/lib/python2.7/site-packages/Cython/Compiler/Nodes.py",
line 354, in generate_execution_code
    stat.generate_execution_code(code)
  File "/Users/mb312/usr/local/lib/python2.7/site-packages/Cython/Compiler/Nodes.py",
line 4536, in generate_execution_code
    if c_op in ('/', '%') and self.lhs.type.is_int and not
code.directives['cdivision']:
AttributeError: 'CCodeWriter' object has no attribute 'directives

This is only for in-place division.  I'm using current trunk:

Cython version 0.17b2

Cheers,

Matthew


More information about the cython-devel mailing list