Skip to content

Commit

Permalink
Use __slots__ to reduce memory footprint Cache and Field
Browse files Browse the repository at this point in the history
  • Loading branch information
eltbus committed Jan 21, 2024
1 parent dbd31f2 commit 3b0eef8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions multipart/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def parse_options_header(value):


class Cache(Generic[T]):
__slots__ = ('_value', '_is_set')

def __init__(self):
self._value: Optional[T] = None
self._is_set: bool = False
Expand Down Expand Up @@ -165,6 +167,8 @@ class Field:
:param name: the name of the form field
"""
__slots__ = ('_name', '_value', '_cache')

def __init__(self, name: Union[bytes, str]):
self._name = name
self._value: List[bytes] = []
Expand Down

0 comments on commit 3b0eef8

Please sign in to comment.