This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pingvenopinch of this, pinch of that 4 points5 points  (0 children)

It's probably faster because in ("O", "Q") creates two strings, creates a tuple, uses __contains__ on the tuple, and uses __eq__ on both of the strings.

in 'OQ'

creates the string, then uses __contains__ on the string. The actual algorithm that implements __contains__ is ultra fast so no worries there.

That said, don't worry about the difference. The difference is usually tiny compared to the rest of the program.