Skip to content

Coercing a sliced C array to Python should create a list #2159

Description

@scoder

Cython already copies a C array into a Python list automatically on object coercion. It should do the same for sliced C arrays, e.g.

def test():
    cdef int i
    cdef int a[100]
    for i in range(100):
        a[i] = i**2
    return a[:20]  # rejected by type analysis

Currently results in
Cannot convert 'int *' to Python object.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions