LWN: Comments on "NumPy 1.20 has been released" https://lwn.net/Articles/847039/ This is a special feed containing comments posted to the individual LWN article titled "NumPy 1.20 has been released". en-us Fri, 17 Oct 2025 19:10:14 +0000 Fri, 17 Oct 2025 19:10:14 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net NumPy 1.20 has been released https://lwn.net/Articles/847306/ https://lwn.net/Articles/847306/ cozzyd <div class="FormattedComment"> You probably avoid a copy too, which can be significant if it&#x27;s a big array?<br> </div> Thu, 25 Feb 2021 06:59:00 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847297/ https://lwn.net/Articles/847297/ leephillips <div class="FormattedComment"> Thank you for your kind words. It’s a privilege to write for LWN’s readers.<br> </div> Thu, 25 Feb 2021 03:16:12 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847296/ https://lwn.net/Articles/847296/ himi <div class="FormattedComment"> Thank you for this and your other articles covering aspects of scientific computing - they&#x27;ve been very informative and interesting. And thank you to LWN for providing the platform on which they&#x27;re hosted.<br> </div> Thu, 25 Feb 2021 02:32:16 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847289/ https://lwn.net/Articles/847289/ atai <div class="FormattedComment"> never mind. you already answered the question<br> </div> Wed, 24 Feb 2021 23:48:08 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847288/ https://lwn.net/Articles/847288/ atai <div class="FormattedComment"> <font class="QuotedText">&gt; Half-ways through the competition we realized that it was not possible to solve that problem using Java. </font><br> <p> What is it with Java that makes it impossible?<br> </div> Wed, 24 Feb 2021 23:47:15 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847225/ https://lwn.net/Articles/847225/ mhvk <div class="FormattedComment"> Indeed, it just extends `where` to the wrappers around ufunc reductions (`np.logical_and.reduce` and `np.logical_or.reduce` in this case), really remedying an oversight from when I implemented `where` for reductions... I think the advantage is clearer for taking the mean, etc. For `any` and `all`, what would be nice is to have proper short-circuiting, but that is still on the wish list.<br> <p> p.s. What makes `ndarray` so particularly nice is how it deals with strides to allow views of many forms into the array. This is nicely described in the &quot;array programming with numpy&quot; article; see <a href="https://ui.adsabs.harvard.edu/abs/2020Natur.585..357H/abstract">https://ui.adsabs.harvard.edu/abs/2020Natur.585..357H/abs...</a><br> </div> Wed, 24 Feb 2021 14:49:12 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847223/ https://lwn.net/Articles/847223/ leephillips <div class="FormattedComment"> As far as I can tell the results should be the same. This is an extension of the `where` keyword argument that was added to `numpy.reduce` in v. 1.17. Both when using the `where` keyword argument in when using `logical_and`, the Boolean mask array is broadcast to match the dimensions of the array in the first argument. There could be performance differences.<br> </div> Wed, 24 Feb 2021 14:05:20 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847222/ https://lwn.net/Articles/847222/ quietbritishjim <div class="FormattedComment"> My point was that the terminology was probably chosen to avoid distracting comments about Python&#x27;s speed instead of constructive comments about the article content. Your comment only reinforces that.<br> <p> It&#x27;s sadly a pattern on LWN articles about some new aspect of Python or its libraries: one of the top comments is about how slow Python is (often _the_ top comment, as in this case). It&#x27;s one of the few times I wish LWN comments had Reddit style vote buttons. Not because I disagree, but just because it&#x27;s off-topic and stifles more interesting discussions.<br> </div> Wed, 24 Feb 2021 13:51:43 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847220/ https://lwn.net/Articles/847220/ pizza <div class="FormattedComment"> I recently replaced a relatively simple text parsing/collating python script with a nearly-identical one written in perl, and the runtime dropped from ~30s to ~3s.<br> <p> (The original script was python 2, and I started out by trying to port it to python 3. Unfortunately it needed to handle sometimes-broken unicode so rewriting it in perl turned out to be far more expedient. And as it turned out, an order of magnitude faster)<br> <p> Anectdotally, the only times I&#x27;ve seen where python is &quot;fast&quot; is when you&#x27;re able to hand off batches of data to native-compiled libraries. (NumPy being a prime example of this..)<br> <p> </div> Wed, 24 Feb 2021 13:02:42 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847219/ https://lwn.net/Articles/847219/ hkario <div class="FormattedComment"> Except that Python does not manage 20mph in this analogy, it easily manages highway speeds. What it&#x27;s not well suited for is winning Daytona 500.<br> </div> Wed, 24 Feb 2021 12:05:00 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847218/ https://lwn.net/Articles/847218/ thumperward <div class="FormattedComment"> Yes, but very few people would argue that Python is slow relative to doing things with pencil and paper. For the vast majority of computing tasks, Python is plenty fast on contemporary hardware. But it is nevertheless the case that when one considers which contemporary languages Python is slow relative to, the answer is &quot;nearly all of them&quot;. You wouldn&#x27;t see a review of a car which had a top speed of 20mph described as &quot;relatively slow&quot; despite this being wildly better than foot speed.<br> </div> Wed, 24 Feb 2021 11:27:10 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847217/ https://lwn.net/Articles/847217/ pgdx <div class="FormattedComment"> I don&#x27;t remember it precisely, it&#x27;s probably 7 years ago, or so, but the problem was JVM startup combined with slow IO (parsing integers from stdin).<br> </div> Wed, 24 Feb 2021 11:17:34 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847215/ https://lwn.net/Articles/847215/ ju3Ceemi <div class="FormattedComment"> Starting a JVM is time consumming, and we are talking about a couple of second max for the whole program to run<br> </div> Wed, 24 Feb 2021 10:58:04 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847214/ https://lwn.net/Articles/847214/ sandsmark <div class="FormattedComment"> I agree with you, but now I got curious about the problem that wasn&#x27;t possible (or at least feasible in a competition) to solve with Java. Do you remember what problem was, or at least the broad strokes?<br> </div> Wed, 24 Feb 2021 10:39:15 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847212/ https://lwn.net/Articles/847212/ quietbritishjim Isn't the new where argument: <pre> np.any(ri &lt; 3, where=ri%2 == 0) </pre> the same as using the existing logical_and: <pre> np.any(np.logical_and(ri &lt; 3, ri%2 == 0)) </pre> ? If so, is there any benefit to the new notation? I suppose perhaps speed? I see it's slightly more consise, but the composing two functions seems clearer to me and is much more flexible. Wed, 24 Feb 2021 09:03:53 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847210/ https://lwn.net/Articles/847210/ quietbritishjim <div class="FormattedComment"> Python will execute millions or even 10s of millions of instructions per seconds. (As the sibling comment points out, I am talking about the CPython runtime specifically.) Personally, that sounds very fast (in absolute terms) to me! Of course, you might disagree, since what counts as &quot;fast&quot; in absolute terms is so subjective. What is difficult to argue is that Python is slow relative to many other languages in common use. That&#x27;s probably why the article author said &quot;relatively slow&quot;, in the hope that the preciseness of that would avoid this whole discussion. Oh well.<br> <p> On the note of speed and libraries like numpy, I&#x27;ll point out that C libraries like numpy (and even some built in modules) release Python&#x27;s global interpreter lock (GIL) while doing computations. So not only do they speed up the throughput in the current thread, they allow other threads to do work concurrently. (The GIL is also released when doing IO like reading from a file.)<br> </div> Wed, 24 Feb 2021 08:31:43 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847209/ https://lwn.net/Articles/847209/ pgdx <p>I used to do competitive programming, where you need to write programs/algorithms that solve large instances of problems with typically 1–5 seconds time limit. </p><p> Python is a slow <em>runtime</em>, yes. However, we have seen several problems in competitions where Python (running on pypy, of course) outperforms other languages, e.g. Java. </p><p> Indeed, we once created a problem that we implemented solutions for in every language accept Java (go figure). We just assumed that since Python ran well within time limits, Java would manage too. </p><p> Half-ways through the competition we realized that it was not possible to solve that problem using Java. </p><p> I'm not a programming language expert, but I can accept your claim that there are "slow languages", however pypy is a quite snappy runtime. </p><p> (Now I teach competitive programming; those who can't do teach.) </p> Wed, 24 Feb 2021 08:12:30 +0000 NumPy 1.20 has been released https://lwn.net/Articles/847207/ https://lwn.net/Articles/847207/ ncm <div class="FormattedComment"> Why call Python a &quot;relatively slow&quot; language? Python is an example of an absolutely slow language. It is slower than the overwhelming majority of languages, and less slow only than extremely slow languages.<br> <p> &quot;Absolutely slow&quot; is unnecessarily verbose. &quot;Relatively slow&quot; is, too. &quot;Slow&quot; is short and correct. Say &quot;Python is a slow language.&quot; Its users know, and have chosen.<br> <p> Just to be clear, I do not mean that slow is the same as bad, or that Python is a bad language. I use it. In most places where we use programs, slow is fast enough. Slower than Python was fast enough to land on the moon. There is enough room in the world for a slow language.<br> <p> But I would not use Python where throughput or latency does matter, anyway not without a lot of help from, e.g., NumPy.<br> </div> Wed, 24 Feb 2021 06:19:08 +0000