Re:The fastest way to detect a vowel in a string
by windward on Thursday June 26, 2025 @09:52AM
(#44387433)
I don't think the size is trivial, it's 4 times the cache length on x64
Re:The fastest way to detect a vowel in a string
by glangdale on Tuesday July 01, 2025 @04:03AM
(#44431685)
I'm not sure what you mean here. A single cache line is 64B, and this table would thus occupy 4 cache lines, but typical x86 cache sizes are 32K or for more recent cores 48K. Whether consuming 1/512th or 1/768th of your level 1 cache is excessive is a value judgement, but most people wouldn't think so.
The fastest way to detect a vowel in a string on any reasonable architecture (Intel or AMD equipped with SIMD of some kind) is using 3-4 instructions which will process 16/32/64 (depends on SIMD length) bytes at once. Obviously access to these will require using a Python library that exposes SIMD.
Leaving SIMD aside, a flat byte array of size 256 will outperform a bitmap since it's always faster to look up bytes in an array than bits in a bitmap, and the size is trivial.