this post was submitted on 15 Jun 2025
14 points (100.0% liked)

LibreByte

190 readers
22 users here now

Tecnologías libres para la comunidad.

Puedes enviar post a esta Comunidad sobre Tecnologías Libres en Español o Inglés.

founded 8 months ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] Takapapatapaka@lemmy.world 5 points 2 months ago

For anyone curious but not wanting to read the article :

The python fastest ways of the base article are mainly using a for loop and using regex (first one is faster on small string, regex becomes faster around 25 characters).

For loop :

def loop_in(s):
    for c in s:
        if c in "aeiouAEIOU":
            return True 
    return False 

Regex :

import re
def regex(s):
    return bool(re.search(r'[aeiouAEIOU]', s))

There are updates to the article, suggesting faster ways. First one uses the find() function, second one swaps the strings of the For Loop method :

def loop_in_perm(s):
        for c in "aeiouAEIOU":
            if c in s:
                return True
        return False