Skip to content

add version of Richards that uses super() #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2023
Merged

Conversation

carljm
Copy link
Member

@carljm carljm commented Apr 14, 2023

Currently, none of the benchmarks in pyperformance exercise super() method calls significantly. But real-world modern object-oriented Python code often does (one source: Instagram server codebase uses lots of super() method calls, some in hot paths.)

To correct this gap in visibility, this PR adds a copy of the Richards benchmark that is modified to use super() calls. Existing super-method calls that were done by naming the base class directly (Task.__init__(self, ...)) are modified to use super(), and the already-polymorphic Task.fn method is modified slightly such that overrides now call up to the base method using super().

If we accept that Richards is a roughly reasonable representation of some object-oriented Python code, I think this is a similarly reasonable representation of the real-world use of super() in such code.

Thanks to @pablogsal for this suggestion.

@carljm
Copy link
Member Author

carljm commented Apr 14, 2023

The 3.12 failure looks like an issue building greenlet, not related to this PR.

@hugovk
Copy link
Member

hugovk commented Apr 14, 2023

Yep, see #263 for 3.12+greenlet.

@corona10
Copy link
Member

Nice I will take a look

@corona10
Copy link
Member

corona10 commented Apr 16, 2023

Overall looks good, but why not just replace the Richards to use super()?
I feel the running time of benchmarks is increased these days, due to the increasing number of benchmarks.
Adding benchmarks is good, but let's avoid the duplicated similar workload added if possible.

cc @pablogsal

@carljm
Copy link
Member Author

carljm commented Apr 16, 2023

Overall looks good, but why not just replace the Richards to use super()?

I think the main reason is because this means Richards timing is no longer comparable to previous timings? (I'm not sure if this is an issue or not; I'm quite happy to just change Richards if that's ok with the maintainers.)

@corona10 corona10 closed this Apr 19, 2023
@corona10 corona10 reopened this Apr 19, 2023
@corona10 corona10 closed this Apr 20, 2023
@corona10 corona10 reopened this Apr 20, 2023
@carljm carljm requested a review from mdboom April 24, 2023 22:35
@mdboom
Copy link
Contributor

mdboom commented Apr 25, 2023

This looks good to me. I agree that adding (rather than replacing) is the way to go here. We can always remove the old benchmark once we learn more from this one.

Copy link
Contributor

@mdboom mdboom left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

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

lgtm

@carljm carljm merged commit 974e29c into python:main Apr 25, 2023
@carljm carljm deleted the richards_super branch April 25, 2023 17:33
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.

5 participants