News for hackers. Stuff that matters.
Re:Python 3.11 beta vs. 3.10 benchmark by SemanticStrengh on Thursday May 19, 2022 @05:27AM (#31432433)
JS integers are value types unlike Java?!
Re:Python 3.11 beta vs. 3.10 benchmark by ptx on Thursday May 19, 2022 @07:00AM (#31432927)
On second thought, I'm not sure. Can you observe the number's object identity like you can in Python? Does JavaScript have to allocate a new Number object for each "i++"?

My point was that the Python version of Aardwolf's function call benchmark [1] is definitely using iterators and boxing all numbers, so it's doing a lot more than just calling a function, and the Java equivalent would look something like this:

    Long f(Integer x) {
        return new Long(x.longValue() * x.longValue());
    }

    // ...

    Double v = new Double(0.0);

    Iterator<Integer> range = IntStream.range(0, 100000000).iterator();
    while (range.hasNext()) {
        Integer i = range.next();
        v = new Double(v.doubleValue() + f(i).doubleValue());
    }
[1] https://news.ycombinator.com/item?id=31427506