6 ms·
Numpy is written in C. That's why it's fast. Better: http://benchmarksgame.alioth.debian.org/ http://benchmarksgame.alioth.debian.org/
by ahoge 12y ago
Numpy is written in C. That's why it's fast.
Better: http://benchmarksgame.alioth.debian.org/ http://benchmarksgame.alioth.debian.org/
- wffurr 12y agoYou didn't read the thread. The OPs code used very small arrays and using numpy was slowing the code down by an order of magnitude. The pure python solution is 17x faster.
- Jtsummers 12y agoYour other post [1] is marked as dead. The filters here will do that to duplicate posts (maybe within a time limit?). You may want to reply to that comment again with a rephrasing of this post rather than the same content. [1] https://news.ycombinator.com/item?id=7672744 https://news.ycombinator.com/item?id=7672744
- TillE 12y agoIt's really important to remember that the interface of a VM can be one of the slowest parts. When your LuaJIT code is making a ton of calls to tiny C functions, it's gaining hardly any benefit from the JIT.
- awj 12y agoYeah, things like marshaling data across the interface barrier, or chasing the pointer indirections inherent in calling functions, can have a significant cost. Usually it isn't significant enough, but as always the devil is in the details.
- muyuu 12y agoYep and anyone with any experience in NumPy won't use it that way.
- deleted 12y ago[deleted]
- plus 12y agoNumPy contains no Fortran code, and can be compiled without a Fortran compiler. What NumPy does provide is f2py, which is used to compile SciPy, which does have Fortran code.
- piokuc 12y agoI have found on this page: http://docs.scipy.org/doc/numpy/user/install.html http://docs.scipy.org/doc/numpy/user/install.html following quote: "Various NumPy modules use FORTRAN 77 libraries, so you’ll also need a FORTRAN 77 compiler installed." And, on the same page: "NumPy does not require any external linear algebra libraries to be installed. However, if these are available, NumPy’s setup script can detect them and use them for building. A number of different LAPACK library setups can be used, including optimized LAPACK libraries such as ATLAS, MKL or the Accelerate/vecLib framework on OS X." The linear algebra libraries mentioned are obviously Fortran libraries. So, it seems like I was wrong saying that Numpy modules are written in Fortran, but it's still not clear to me if only SciPy modules are the ones which call Fortran libs. I will delete my comment above, anyway.
- plus 12y agoLAPACK and BLAS have many implementations, some of which are written in Fortran, but as you've said external LAPACK and BLAS libraries are not necessary to successfully compile NumPy, though they do accelerate certain NumPy routines.
- igouy 12y agospectral-norm Python 3 #5 program (no numpy) http://benchmarksgame.alioth.debian.org/u64q/program.php?test=spectralnorm&lang=python3&id=5 http://benchmarksgame.alioth.debian.org/u64q/program.php?tes... spectral-norm Python 3 #3 program (numpy) http://benchmarksgame.alioth.debian.org/u64q/program.php?test=spectralnorm&lang=python3&id=3 http://benchmarksgame.alioth.debian.org/u64q/program.php?tes... spectral-norm Python 3 #2 program (numpy + ignore separate functions requirement) http://benchmarksgame.alioth.debian.org/u64q/program.php?test=spectralnorm&lang=python3&id=2 http://benchmarksgame.alioth.debian.org/u64q/program.php?tes...
- deleted 12y ago[deleted]