Discussion:
"Python is 71x Slower, Uses 75x More Energy, Than C" - YouTube
(too old to reply)
Lynn McGuire
2024-07-31 00:06:11 UTC
Permalink
"Python is 71x Slower, Uses 75x More Energy, Than C" - YouTube


I am not buying that C++ is slower than Rust.

The referenced paper is:
https://www.sciencedirect.com/science/article/abs/pii/S0167642321000022

Lynn
Bart
2024-07-31 11:15:58 UTC
Permalink
Post by Lynn McGuire
"Python is 71x Slower, Uses 75x More Energy, Than C" - YouTube
   http://youtu.be/U4c6nFGt1iM
Could that guy's voice be any more annoying?

Anyway, some observations:

* CPython (I assume this is Cpython), is of course just a program
written in C. So it's really just a C application ...

* The C results are going to be mostly thanks to the efforts of
aggressively optimising compilers, rather than the language itself. I
guess they weren't using Tiny C!

* The test programs are all from the computer language benchmarks game,
which are mostly useless for comparisons. Because entries can choose
their own algorithms, employ multi-threading etc. So it's no surprise
there is such a wide range of results.

* When Python is used for a one-off program that runs in a fraction of a
second, the fact that is is 70 times slower than the C equivalent is
irrelevant. But if you include the build-time for the C, then the Python
may well have used fewer machine resources.
Post by Lynn McGuire
I am not buying that C++ is slower than Rust.
   https://www.sciencedirect.com/science/article/abs/pii/S0167642321000022
It's the computer benchmarks game; I wouldn't pay too much attention.

When I once tested of its programs ('fannkuch') I got these results,
although they are several years old (3 out of 24 shown):

Clang -O3 2.45 secs
Rustc -O 3.2
Tiny C 10.1
Rustc 37.8

Rust in debug mode ran a magnitude slower than optimised releae mode.
Maybe it was interpreted? I never found out why.
Lawrence D'Oliveiro
2024-08-02 02:36:31 UTC
Permalink
There are so many cases where the idea that Python is “slower” than C
really makes no difference to anything important. It matters where the
bottleneck is in CPU performance. But let’s face it, most programs
being written will not encounter such a situation. And even when they
do, it might not be where they think it is
<https://community.asterisk.org/t/no-excute-agi-command/103436/8>.
James Kuyper
2024-08-02 18:59:01 UTC
Permalink
Post by Lynn McGuire
"Python is 71x Slower, Uses 75x More Energy, Than C" - YouTube
   http://youtu.be/U4c6nFGt1iM
I don't know for sure but I suspect part of it is Python using
reference counting for it's memory managment. Maybe they should
compare it to jython.
Post by Lynn McGuire
I am not buying that C++ is slower than Rust.
Rustaceans make a lot of unsupported claims. They also claim without
any support that java is slower than rust. Apparently they are
completely ignorant of the fact that java uses JIT compilation and can
dynamically tune performance hot spots, and if they are using
reference counting to manage memory it's going to perform very badly
compared to Java GC.
Keep in mind that this is not an "unsupported claim" - it's the result
of measurements, with the method used to make the measurements
specified, though not completely. I hove no idea how, but you should be
able to ask the author of the paper to send you copies of the source
code used, and details of the compilation options chosen. In this kind
of academic study, providing such details on request is considered
mandatory.

In order to counter such evidence, you should ideally try to repeat the
tests. You might find that they are biased in some way. For instance,
the Rush versions of the programs might have been written by an expert,
while the C++ versions might have been written by someone who hates C++,
Alternatively, you might find that the particular algorithms chosen
create a bias towards Rust over C++. But you can't simply dismiss this
as due to the author of that study being a Rust fanboy - the study
covers many different languages, and if anything suggests that C vs.
Python is his main interest.
Lawrence D'Oliveiro
2024-08-02 23:59:19 UTC
Permalink
Post by James Kuyper
... and if they are using
reference counting to manage memory it's going to perform very badly
compared to Java GC.
Keep in mind that this is not an "unsupported claim" - it's the result
of measurements ...
Yeah, I wonder why Java fan(atic)s keep spouting that nonsense. Other
languages (Perl, Python) have shown the benefits of having reference
counting as a first resort, only falling back to garbage collection to
handle those (less frequent) cases where it is needed.
Paul
2024-08-03 00:48:54 UTC
Permalink
Post by Lynn McGuire
"Python is 71x Slower, Uses 75x More Energy, Than C" - YouTube
   http://youtu.be/U4c6nFGt1iM
I am not buying that C++ is slower than Rust.
   https://www.sciencedirect.com/science/article/abs/pii/S0167642321000022
Lynn
https://www.reddit.com/r/rust/comments/lb2aeu/ranking_programming_languages_by_energy_efficiency/

"Tests are garbage, they use an Intel i5-4460 with AVX2 but let focus on mandelbrot test

-Rust is compiled with: -O3 and targeting a CPU compatibility of Core2

-C is compiled with: -O3, cpu as native and vectorial support

code and compile options can be checked at
https://github.com/greensoftwarelab/Energy-Languages

"

*******

"A better link imho:

https://sites.google.com/view/energy-efficiency-languages

https://sites.google.com/view/energy-efficiency-languages/setup

Benchmark # images extracted with snippingtool and text-actions
n-body # then spreadsheet, export pdf, pdftotext -layout some.pdf some.txt
fannkuch-redux
spectral-norm
mandelbrot <=== "focus on mandelbrot test"
pidigits
regex-redux

fasta
k-nucleotide
reverse-complement
binary-trees
chameneos-redux
meteor-contest
thread-ring

Version Version
Ada GNAT 6.2.0 Jruby jruby 9.1.7.0
C gcc 6.2.0 Lisp SBCL 1.3.3.debian
C# dotnet 1.0.1 Lua Lua 5.3.3
C++ g++ 6.2.0 Ocaml ocamlopt 4.05.0
Chapel chpl 1.15.0 Pascal fpc 3.0.2
Dart Dart VM 1.24.0-dev.0.0 Perl perl 5.24.0
Erlang Erlang 7.3.1.2 PHP php 7.1.4
F# dotnet 1.0.1 Python python 3.5.2
Fortran ifort 17.0.3 Racket raco 6.8
Go go go1.6.3 Ruby ruby 2.4.1
Hack HipHop VM 3.19.2 Rust ruste 1.16.0
Haskell ghc 8.0.2 Swift swift 4.0-dev
Java jdk 1.8.0_121 TypeScript node 7.9.0
JavaScript node 7.9.0
"

Paul

Loading...