Arseny Boykov <appkille...@gmail.com> added the comment:

Also, do we need to leave compatibility with python <3.8? 
If not, we could use the fact that python 3.8 dicts and sets which are preserve 
order to speed things up even more. Also I'd replace % string formatting with 
f-strings, as they also faster.

And another thing to think about: maybe we can calculate values returned by 
__str__, __repr__ and __invert__ once on member creation, since they not 
supposed to change during its life?

For example __invert__ on Flag does a lot of work on every call:
    def __invert__(self):
        cls = self.__class__
        members, uncovered = _decompose(cls, self._value_)
        inverted = cls(0)
        for m in cls:
            if m not in members and not (m._value_ & self._value_):
                inverted = inverted | m
        return cls(inverted)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39102>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to