-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Coercing a sliced C array to Python should create a list #2159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Or maybe a tuple to avoid assumptions that mutating one would change the
other. IMHO, an explicit list comprehension or list(c_array) might not be
too bad to require to make the fact that it's a copy explicit.
…On Mar 17, 2018 8:47 AM, "scoder" ***@***.***> wrote:
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2159>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAdqgbISOH4fV9I1sWv2ojDfFXjpK1wvks5tfTAQgaJpZM4Su2fU>
.
|
Too late ;) |
I'll note here for whoever wants to fix this issue the places in the documentation that will need to be changed accordingly:
https://github.com/cython/cython/blob/master/docs/src/tutorial/cython_tutorial.rst#primes |
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.
Currently results in
Cannot convert 'int *' to Python object
.The text was updated successfully, but these errors were encountered: