Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: - special case situation when types of `self` and `other` values are the same - save on attribute access and instead treat object as Python int using `PyLong_AsLong` to read numeric value. NOTE: we only do this enums that have int as base class (bypassing flag enums that don't have the same underlying representation) #buildall Benchmark results (subsequent diff) ``` # baseline int (baseline): start 100000000 comparisons Finished in: 6.380038888193667 enum: start 100000000 comparisons Finished in: 19.200770954135805 # check types + use attribute access int (baseline): start 100000000 comparisons Finished in: 6.133592534810305 enum: start 100000000 comparisons Finished in: 11.616515398956835 # check types + PyLong_AsLong int (baseline): start 100000000 comparisons Finished in: 6.21840969985351 enum: start 100000000 comparisons Finished in: 8.569516903720796 ``` Reviewed By: Filip-F Differential Revision: D66850779 fbshipit-source-id: a2adaa542a5097f2707f34db43ecea1d6cec3f81
- Loading branch information