Tell me more ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

How do Python/Numpy arrays scale with increasing array dimensions?

This is based on some behaviour I noticed while benchmarking Python code for this question: How to express this complicated expression using numpy slices

The problem mostly involved indexing to populate an array. I found that the advantages of using (not-very-good) Cython and Numpy versions over a Python loop varied depending on the size of the arrays involved. Both Numpy and Cython experience an increasing performance advantage up to a point (somewhere broadly around $N=500$ for Cython and $N=2000$ for Numpy on my laptop), after which their advantages declined (the Cython function remained the fastest).

Is this hardware defined? In terms of working with large arrays, what are best practices that one should adhere to for code where performance is appreciated?

Plot of execution time relative to looped code for vectorized and Cython implementations

This question (Why isn't my Matrix-Vector Multiplication Scaling?) may be related, but I am interested in knowing more about how different ways of treating arrays in Python scale relative to each other.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.