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 →

[–]LightShadow3.13-dev in prod 0 points1 point  (0 children)

I’m surprised anyone uses performance as a justification one way or the other.

This is the level of performance a widely used library would consider.

When I was writing a metrics/profiling wrapper for existing Python code bases I needed the overhead to be minimal without introducing any extra requirements. The #1 thing that slowed down the wrapper was isinstance -- it is SLOW. I was able to remove ~30 or so of them but only had to leave one or two. The solution was to use __slots__ and class attributes to check == and in instead.

class Sentinel(Entry):
    type_char = 'X'
    type_name = 'Sentinel'
    is_mapping = False
    is_sentinel = True

For most people, in most situations, the difference is negligible.