attrs
attrs copied to clipboard
Eliminate most str.format() and %-formatting
Micro-optimization is the root of all success.
This btw gives us ~6% performance gain on class creation for simple classes, just by being more idiomatic (and getting rid of the mistake called format).
Measured using:
def create(loops):
range_it = range(loops)
d = attrs.define
t0 = pyperf.perf_counter()
for _ in range_it:
@d
class C:
a: int
b: int
return pyperf.perf_counter() - t0
I presume that more complex classes give us even bigger gainzzz.