Reputation: 39
Hy volk,
is there any fastest ways to recognize if given char is emoji?
Till this moment i found the following solution:
import emoji
character in emoji.UNICODE_EMOJI
But it seems to be a not the best one, because to check if given char is in the dict, because you need to compute hash function and make lookup. What I mention, maybe it it possible just to check, if emoji Code point is inside of some range of Unicode code points, which are emojis. Any ideas, how to implement it?
Thx u in advance!
Upvotes: 0
Views: 341
Reputation: 562
If what you are looking for is faster lookups in a list and you don't have any duplicates, you can try replacing list()
with a set()
instead.
Similar problem: https://stackoverflow.com/a/5993659/7570485
Update:
As far as I know, you can't get any faster lookups than a dict()
. Average time complexity for dict lookup is O(1)
. You could try intern()
in sys
module to gain a small performance boost.
Upvotes: 1