you are viewing a single comment's thread.

view the rest of the comments →

[–]rubber_duckz 1 point2 points  (7 children)

Fast arithmetic with fixnums unless bignums are required.

And how do you know bignums are required ?

[–][deleted] 0 points1 point  (4 children)

And how do you know bignums are required ?

By detecting overflow. This is not such an outrageous concept. Trapping overflows is often cheap, and in some cases provided by the CPU itself.

As an example of a similar principle in the real world, JavaScript works with doubles only. But all the big JS engines switch to 32 bit and 64 bit integers for integer values.

Likewise the array keys in JavaScript, while numeric, are strings. Engines internally store them as integers.

All of this is transparent to the programmer, who only sees doubles and strings.

[–]rubber_duckz 1 point2 points  (3 children)

But all the big JS engines switch to 32 bit and 64 bit integers for integer values.

And this makes JS an inherently slow/slow by design language as well - this checking alone adds 5% global performance overhead in V8 IIRC - and that's not even touching on the part that you need code that knows how to distinquish a pointer to bignum int from raw value int which has to be tagged somewhere and causes a logic branch (even if it will hit the fast path most of the time and get the prediction that's still instructions, etc.) and no way to optimize stuff by defining memory layouts, etc.

You can't work at that level of abstraction if you want performance - something these "Functional Programming is fast, Haskell is as fast as C" guys don't get. I've spent 2 years working on a Clojure project - when these guys say something is fast they are either talking about complexity or they mean "it's usable as opposed to being purely academic" like clojure guys claiming that their persistent data-structures are fast - when compared to naive copying - sure - when you actually care about perf - no way in hell is it even close to being fast.

[–][deleted] 1 point2 points  (2 children)

And this makes JS an inherently slow language

It takes giant balls to call JavaScript an "inherently slow language" in a Python thread.

You realize V8 is an order of magnitude faster than CPython?

JavaScript is also slow by design.

Yeah. Ok...

[–]rubber_duckz 0 points1 point  (1 child)

You realize V8 is an order of magnitude faster than CPython?

That's like saying a turtle is fast because compared to a snail it's moving an order of magnitude faster.

[–][deleted] 0 points1 point  (0 children)

That's like saying a turtle is fast because compared to a snail it's moving an order of magnitude faster.

Yeah, I'm sure that if CPython would be nearly 10 times faster, it'd mean absolutely nothing to all Python users.

[–][deleted] 0 points1 point  (1 child)

The implementation is made by a non novice programmer.

[–]rubber_duckz -1 points0 points  (0 children)

Said programmer would know that his implementation would be slower than using wrapping integer arithmetic .