Closed hgreenbl closed 2 years ago
Agreed about a utility library. Let's make it a separate issue for a wishlist later. @hgreenbl Will you open this issue?
Why classmethod instead of staticmethod?
Let me know what you think on comments. =)
Agreed about a utility library. Let's make it a separate issue for a wishlist later. @hgreenbl Will you open this issue?
Why classmethod instead of staticmethod?
Did you read the docs I linked?
A class method receives the class as an implicit first argument, just like an instance method receives the instance. ... If a class method is called for a derived class, the derived class object is passed as the implied first argument.
This way, any class that inherits from Benchmark also inherits (if it doesn't choose to override) the default generate_benchmarks
implementation, which will return a single-item list but call the derived class's constructor to populate it.
(It also reduces repetition, which improves maintainability for the usual reasons.)
Read the docs, not sure how this is different from staticmethod for our use case.
Probably my lack of understanding, not arguing, but need to understand
Makes the default
generate_benchmarks
heritable (are you familiar with the semantics of@classmethod
?) and simplifies the interface a bit.We should consider adding a utility function for the cartesian-product pattern (e.g. c1b14cdd772f3d6acae60659ac17fcac13862603) since it's likely to be common.