Skip to content

Conversation

@hynek
Copy link
Member

@hynek hynek commented Aug 7, 2022

Micro-optimization is the root of all success.

@hynek
Copy link
Member Author

hynek commented Aug 10, 2022

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.

Copy link
Member

@Tinche Tinche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hynek hynek merged commit 6151683 into main Aug 10, 2022
@hynek hynek deleted the more-f-strings branch August 10, 2022 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants