django / asgiref

ASGI specification and utilities
https://asgi.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
1.46k stars 207 forks source link

Use EAFP approach in local.py #463

Open sevdog opened 3 months ago

sevdog commented 3 months ago

This aims first of all to align the code of _CVar.__delattr__ with that of _Cvar.__getattr__.

Then to use the EAFP approach in Local._lock_storage, to improve efficiency since the hasattr method is implemented by catching the AttributeError of a getattr call.

I know that this should save just a couple of CPU cycle, but I belive it is worth it.