Improvement: Base FixtureArgKey
s on param values if possible, not param indices by sadra-barikbin · Pull Request #11271 · pytest-dev/pytest (original) (raw)
Thanks @sadra-barikbin, the implementation is very clean :)
This has come up previously in #9350. The main worry is about users using very large parametrize values. Arguably Hashable
would exclude such values (such as numpy.array
or large dicts) and fall back to the fast param index comparison. But I'm still pretty sure that we'll get "you made pytest slow" complaints from users using big hashable values like tuples etc, which we will now start hashing and comparing by value.
That's why I'm a bit scared to merge this as-is. After discussions in #9350, @haxtibal came up with a refinement of the idea in #9420, which keeps the Hashable business but adds an opt out for users who get hit by the "slow hashable value" problem. The workaround is to add a third comparison method, this one by parameter ID.
Unfortunately I dropped the ball on #9420 but there was fruitful discussion there.
Let me know what you think.