[Cython] memory view creation during cascaded assignments

Stefan Behnel stefan_ml at behnel.de
Sat Jul 5 12:34:48 CEST 2014


Hi,

I started optimising cascaded assignments a little to reduce the
unnecessary duplication of coercions. While doing that, I found this test
in memslice.pyx:

'''
def cascaded_buffer_assignment(obj):
    """
    >>> A = IntMockBuffer("A", range(6))
    >>> cascaded_buffer_assignment(A)
    acquired A
    acquired A
    released A
    released A
    """
    cdef int[:] a, b
    a = b = obj
'''

It's explicitly tested for that we create two independent memory views in
this case. Is there an actual reason for this? As long as the types of a
and b are identical, I don't see why we would want to request the buffer twice.

Stefan


More information about the cython-devel mailing list