Use slots in attrs classes where possible (#8296)

slots use less memory (and attribute access is faster) while slightly
limiting the flexibility of the class attributes. This focuses on objects
which are instantiated "often" and for short periods of time.
This commit is contained in:
Patrick Cloke 2020-09-14 12:50:06 -04:00 committed by GitHub
parent d2a3eb04a4
commit aec294ee0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 33 additions and 50 deletions

View file

@ -311,7 +311,7 @@ def _parse_cache_control(headers: Headers) -> Dict[bytes, Optional[bytes]]:
return cache_controls
@attr.s()
@attr.s(slots=True)
class _FetchWellKnownFailure(Exception):
# True if we didn't get a non-5xx HTTP response, i.e. this may or may not be
# a temporary failure.

View file

@ -76,7 +76,7 @@ MAXINT = sys.maxsize
_next_id = 1
@attr.s(frozen=True)
@attr.s(slots=True, frozen=True)
class MatrixFederationRequest:
method = attr.ib()
"""HTTP method