News for hackers. Stuff that matters.
Re:Data structures and algorithms I actually used while work... by ajuc on Wednesday July 15, 2020 @08:14AM (#23844078)
I can't be sure without measuring, but I strongly suspect the overhead will be mostly in tuple packing/unpacking and GC.

And I instinctively distrust Sufficiently Smart Compilers ;)

Re:Data structures and algorithms I actually used while work... by eru on Wednesday July 15, 2020 @09:38AM (#23845025)
Oh, your compiler doesn't have to be sufficiently smart. It merely has to avoid premature optimization: see this classic paper https://dspace.mit.edu/handle/1721.1/5753 by Guy Steele.

> I can't be sure without measuring, but I strongly suspect the overhead will be mostly in tuple packing/unpacking and GC.

I guess that's the same overhead as in this imperative version:

    a, b = 0, 1
    for _ in range(n):
      a, b = b, a + b