openxla / xla

A machine learning compiler for GPUs, CPUs, and ML accelerators
Apache License 2.0
2.39k stars 358 forks source link

[XLA:Python] Tiny optimization in traceback hashing. #14251

Closed copybara-service[bot] closed 19 hours ago

copybara-service[bot] commented 5 days ago

[XLA:Python] Tiny optimization in traceback hashing.

It's slightly faster to define a tp_hash slot than a __hash__ method, notably because it saves a PyLong construction for the hash return value. While we're here tp_richcompare is slightly faster to dispatch than eq.

This isn't a particularly important optimization but I noticed it looking at a profile.