Let's call the styles a tie.  Using the SOWPODS scrabble wordlist (no
currency symbols, so False answer):

>>> unicode_currency = {chr(c) for c in range(0xFFFF) if 
>>> unicodedata.category(chr(c)) == "Sc"}
>>> wordlist = open('/usr/local/share/sowpods').read()
>>> len(wordlist)
2707021
>>> %timeit any(unicodedata.category(ch) == "Sc" for ch in wordlist)
176 ms ± 1.75 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
>>> %timeit any(unicodedata.category(ch) == "Sc" for ch in set(wordlist))
17.8 ms ± 121 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
>>> bool(set(wordlist) & unicode_currency)
False
>>> %timeit bool(set(wordlist) & unicode_currency)
18 ms ± 216 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

Of course, this is a small character set of 26 lowercase letters (and
newline as I did it).  A more diverse alphabet might tip the timing
slightly, but it's going to be a small matter either way.

On Fri, Jun 2, 2023 at 7:49 PM Chris Angelico <ros...@gmail.com> wrote:
>
> On Sat, 3 Jun 2023 at 09:42, David Mertz, Ph.D. <david.me...@gmail.com> wrote:
> >
> > Yeah... oops. Obviously I typed the version in email. Should have done it 
> > in the shell. But you got the intention of set-ifying the characters in the 
> > large string.
>
> Yep. I thought of that as I was originally writing, but absent
> benchmarking data, I prefer the simplest way of writing something.
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/BVPDSXXOCOWZ5G2THPB3ZVG6VPXDBE24/
> Code of Conduct: http://python.org/psf/codeofconduct/



-- 
The dead increasingly dominate and strangle both the living and the
not-yet born.  Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/Q2N4ZJHEJN4XP4S43K5V3RPMHXDMOUOH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to