Why NumPy is so important?

原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/12243889.html

NumPy

One of the reasons NumPy is so important for numerical computations in Python is because it is designed for efficiency on large arrays of data.

There are a number of reasons for this:

  • NumPy internally stores data in a contiguous block of memory, independent of other built-in Python objects. NumPy’s library of algorithms written in the C language can operate on this memory without any type checking or other overhead. NumPy arrays also use much less memory than built-in Python sequences.
  • NumPy operations perform complex computations on entire arrays without the need for Python for loops.

e.g.

Conclusion

NumPy-based algorithms are generally 10 to 100 times faster (or more) than their pure Python counterparts and use significantly less memory.

Reference

Python for Data Analysis Second Edition

猜你喜欢

转载自www.cnblogs.com/agilestyle/p/12243889.html
今日推荐