Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-126156: Improve performance of creating Morsel objects #126157

Merged
merged 10 commits into from
Oct 31, 2024
5 changes: 3 additions & 2 deletions Lib/http/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,16 @@ class Morsel(dict):
"samesite" : "SameSite",
}

_reserved_defaults = dict.fromkeys(_reserved, "")

_flags = {'secure', 'httponly'}

def __init__(self):
# Set defaults
self._key = self._value = self._coded_value = None

# Set default attributes
for key in self._reserved:
dict.__setitem__(self, key, "")
dict.update(self, self._reserved_defaults)
bdraco marked this conversation as resolved.
Show resolved Hide resolved

@property
def key(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved performances of creating :py:class:`~http.cookies.Morsel` objects by a factor of 3.8x.
Loading