3 ms·
One of the more painful things: many bool fields with byte sized bools
- jcgrillo 3y agoThis is what I have open in my other tab: https://ferrilab.github.io/ferrilab/bitvec.html https://ferrilab.github.io/ferrilab/bitvec.html
- masklinn 3y ago> lang that uses byte sized bools Isn’t that pretty much all of them? The langages where that’s not the case are usually those using pointer-sized bools.
- deleted 3y ago[deleted]
- ninja3925 3y agoIt can be done for performance reason I assume. Numpy for instance does that: https://numpy.org/doc/stable/user/basics.types.html https://numpy.org/doc/stable/user/basics.types.html
- Arech 3y agoyes, exactly. Access/modification of a directly addressable byte is much faster than some bit of it. If I'm not mistaken, on Win32 `BOOL` data type is defined even worse to a 32bit int (this C API was devised way before `bool` has made it's way into C), so 8bits isn't even the worst case scenario :D
- binarymax 3y agoCan’t believe it’s 9 years old at this point, but I made this for a project a while ago to solve this problem in JS. https://www.npmjs.com/package/bitflags https://www.npmjs.com/package/bitflags
- eska 3y agoThey tried to make this convenient with std::vector<bool> in C++, which turned out to be a bad idea in general. It should also be pointed out that storing those booleans as bits is not the only alternative. For a trivial example one could have millions of sorted bools and just store how many are true, then storage becomes constant.