Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Which means you can implement yours to fit your needs.

Which this doesn't, as zip is an expression and multi-sequence loops aren't.

> https://docs.rs/itertools/latest/itertools/macro.izip.html

External libraries aren't part of a language.

> Which is not what I wrote.

I admit, I read over the "almost" in "you almost never need more than 3".

> It also could hardly be less relevant: it's an issue in an AoS structure because all your objects have that overhead, therefore that's your total overhead.

> Here it's 15 or 25% padding in a single value within a stackframe. You're probably wasting more stackframe space due to the compiler not bothering reusing temporally dead locations.

That's not true: arrays are byte-addressable so inside an array the alignment can be shorter. An array of 121 33-byte values is 3993 bytes in size, an array of 121 usizes is 968 bytes in size, and assuming enums resolve to 32-bit values an array of 121 enums is also 484 bytes in size. There is no overhead here.

This has advantages and disadvantages. Unaligned access is slower in general but in many cases and unaligned array can be faster because of how many of its entries can be loaded into the CPU cache. There's no definite advantage here in terms of CPU performance, but in terms of RAM usage there is.

> Until they are not.

When does a for loop ever become faster than a generator? The values being mapped over are already evaluated, there is no lazy loading+early stopping to take advantage of the generator.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: