TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Python consumes 38x more energy than Java

52 点作者 misiax将近 2 年前

17 条评论

boesboes将近 2 年前
The actual benchmark: <a href="https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;performance&#x2F;spectralnorm.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;...</a><p>EDIT: fwiw, classic Fortran is twice as fast as java :P As is Rust, but that&#x27;s less funny to me
评论 #36707333 未加载
评论 #36707205 未加载
评论 #36707220 未加载
评论 #36712257 未加载
marginalia_nu将近 2 年前
One should always be skeptical of these sorts of benchmarks, especially against Java, and I say this as primarily a Java developer.<p>Well optimized Java is very lean and can be incredibly performant, but the median modern Java app is an obese cronenberg made out of gigabytes of SpringBoot dependencies. That&#x27;s not particularly fast; and well optimized python will run circles around it.
评论 #36707219 未加载
评论 #36707265 未加载
评论 #36709499 未加载
misja111将近 2 年前
Amazing. I have seen this list popping up in my LinkedIn feed for more than a year already and it keeps coming back.<p>While any benchmark is of course interesting when considered on its own, the conclusions that people draw from this list tend to be complete nonsense: &quot;Python is bad for the environment&quot;, &quot;we should switch to language xxx to combat global warming&quot; etc.<p>First of all, especially for the slower languages in this list, it is extremely rare that application code written in that language is the bottleneck of a performance critical application. Typically the bottlenecks of every day applications tend to be databases and network. If you need heavy number crunching, there tend to be excellent libraries available written in lower level languages, such as e.g. for Python NumPy and Pandas. If you are really concerned about the energy footprint of your application, you&#x27;re probably better off with optimizing these components. Or optimizing the higher level architecture of your own application, which tends to be a lot easier in a higher level langguage.<p>Second, coding in a faster language is often not economically possible. Programming the same application in C will normally take much longer than coding it in Python. Developing time costs money and can also mean loss of opportunity.<p>And finally, the &#x27;greenest&#x27; language of them all was not even included in this list: assembly. I guess the author must have realized in the back of his head that such a difficult language wasn&#x27;t a realistic option for switching to a more energy efficient solution. He&#x2F;she just failed to realize that this argument applies to many other languages as well.
评论 #36709714 未加载
评论 #36708066 未加载
评论 #36707628 未加载
评论 #36712896 未加载
Uninen将近 2 年前
Even more clickbaity title would have been &quot;Python consumes 70x more energy than Rust&quot;
评论 #36707237 未加载
评论 #36707224 未加载
评论 #36712429 未加载
评论 #36707207 未加载
_han将近 2 年前
I would like to point out that the data in the table is from 2017, and CPython recently focused a lot on performance.
boredumb将近 2 年前
Just write in Rust, it&#x27;s easier to build good software than either of these languages (yea, yea, do you data analyst stuff in python until you start using POLARS). At this point it&#x27;s a far superior ecosystem from a developer experience point of view and the fact it&#x27;s going to get you as close to efficient as possible without you thinking too far into it is a welcome side effect.<p>Using VScode with the Sqlx package I get compile time errors on my SQL - as a result I haven&#x27;t ran a binary with a typo from my SQL in the last 12 months.
评论 #36710447 未加载
评论 #36707487 未加载
评论 #36707421 未加载
awelxtr将近 2 年前
Does this table take into account energy used while developing&#x2F;maintaining?
评论 #36707276 未加载
评论 #36707392 未加载
radicalbyte将近 2 年前
This is why I&#x27;m learning Rust: C# gives fast development speeds than Python with decent performance. Python and Go for when their native libraries smoke C# and now Rust for performance or low level.
评论 #36709741 未加载
pella将近 2 年前
The research: &quot;Energy Efficiency across Programming Languages&quot; SLE’17, October 23–24, 2017<p>PDF: <a href="https:&#x2F;&#x2F;repositorio.inesctec.pt&#x2F;bitstream&#x2F;123456789&#x2F;5492&#x2F;1&#x2F;P-00N-4CX.pdf" rel="nofollow noreferrer">https:&#x2F;&#x2F;repositorio.inesctec.pt&#x2F;bitstream&#x2F;123456789&#x2F;5492&#x2F;1&#x2F;P...</a><p>The human mental energy required for programming, unfortunately, has not been measured. ;-)
bigfryo将近 2 年前
So python programmers are destroying the planet.. I just knew it all along
zelphirkalt将近 2 年前
While Java&#x27;s compiler or JIT is probably one of the most optimized softwares in existence, how do we measure, what overhead the language nudges the programmers to build? I am thinking of AbstractProviderFactoryProxy and similar. Or that for a very long time it forced you (or still does to a degree) to put everything into classes, breeding 1 or 2 generations of programmers, who see a noun and jump to making a class and then subsequently initializing the class to be able to call a method, which actually would only need to be a standalone function.<p>It probably does not balance the 38x, and probably the JIT optimizes parts of it away, but surely the cost is far from zero.<p>Also what about the computational resources it takes to just run a JVM, compared to running a Python program?
评论 #36707490 未加载
评论 #36709808 未加载
评论 #36707547 未加载
mg将近 2 年前
Is Python&#x27;s &quot;values don&#x27;t change, they get replaced by new ones stored elsewhere&quot; approach what makes it slow?<p>I would like to see some micro-benchmarks which pin down the bottlenecks.<p>For example, this minimal benchmark with one variable and a few control structures:<p><pre><code> x=0 for i in range(int(10e6)): if i&lt;50: x=x+1 print (x) </code></pre> Runs 5 times slower here than the same in PHP:<p><pre><code> $x=0; for ($i=0; $i&lt;10e6; $i++) if ($i&lt;50) $x++; echo &quot;$x\n&quot;; </code></pre> Tested with:<p><pre><code> time python3 loop.py </code></pre> Which gives me 0.31s<p>And:<p><pre><code> time php loop.php </code></pre> Which gives me 0.06s<p>A factor of five seems to be roughly the average when comparing Python to PHP for a bunch of different code constructs I tried.
评论 #36707518 未加载
评论 #36713081 未加载
Rochus将近 2 年前
There is a more recent paper by Pereira et al. from 2021 (see <a href="https:&#x2F;&#x2F;www.sciencedirect.com&#x2F;science&#x2F;article&#x2F;abs&#x2F;pii&#x2F;S0167642321000022" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.sciencedirect.com&#x2F;science&#x2F;article&#x2F;abs&#x2F;pii&#x2F;S01676...</a> ); if geomean is used (which is the correct method) instead of what they apparently do in the paper, there is yet a different order (see <a href="http:&#x2F;&#x2F;software.rochus-keller.ch&#x2F;Ranking_programming_languages_by_energy_efficiency_evaluation.ods" rel="nofollow noreferrer">http:&#x2F;&#x2F;software.rochus-keller.ch&#x2F;Ranking_programming_languag...</a>).
评论 #36712083 未加载
fancyfredbot将近 2 年前
C++ uses 34% more energy than C?<p>I thought C code was generally also valid C++ code and so you really should be able to get the same performance and energy consumption. Very odd.
评论 #36707497 未加载
评论 #36712563 未加载
tmaly将近 2 年前
I can see C having 1.00 in table 4 in the article.<p>But how does Python get 71.90 and JavaScript 4.45 ?<p>Something seems off there.
评论 #36715050 未加载
评论 #36714026 未加载
number6将近 2 年前
So Python is 38x more powerful?!
jjaken将近 2 年前
Now compare mental energy