Closed rittneje closed 2 years ago
This is true, but I'm not sure that the small performance increase is worth the small potential backward incompatibility.
Seconded. The performance of assert_that
is not not-important; it's called at least once per asserted match, after all. But, I'd rather see us invest in matcher performance if we see concrete benchmarks showing that those details matter, and in that case we'll try to improve those instead.
Currently
assert_that
will first callmatches
, and then if that returns false, it goes back and callsdescribe_mismatch
. Consequently,assert_that
is wastefully checking the same things twice in a row when something fails. (In fact, many Matchers implementdescribe_mismatch
by simply callingmatches
.) https://github.com/hamcrest/PyHamcrest/blob/498e031815312485cb9fb54a88291d3eb5735efd/src/hamcrest/core/assert_that.py#L65-L73Since the description is already an optional parameter to
matches
, it would make more sense forassert_that
to pass one in the first place.