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
Make list_cy more idiomatic #3
Conversation
I had already tried to use |
Chiming in here, I tried basically the same optimization/cleanup that @boothby did, on my machine I got almost an order of magnitude speedup:
Where list_cy is the optimized module and list_cyo is the code as you have right now in the repo. Give this a double check, it certainly improves times for cython. |
FWIW, the equivalent change to the Julia version would also be more idiomatic, and much quicker:
Similar changes could also be made to |
count += internal_list[j] | ||
cpdef float iterate_list(list a_list): | ||
cdef double count = 0, d | ||
cdef int i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i
is unused here?
new_list.append(0.01) | ||
a_list.append(new_list) | ||
return a_list | ||
return [[0.01]*(10**4) for _ in range(10**4)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i
, j
are also unused here
This is a more idiomatic implementation of cy_list, which avoids several performance pitfalls. On my machine, this results in about a 2x improvement in performance. This PR is incompatible with #2; maybe they should be separate tests.