mirror of
https://github.com/python/cpython.git
synced 2024-11-21 12:59:38 +01:00
gh-126156: Improve performance of creating Morsel
objects (#126157)
Replaces the manually constructed loop with a call to `dict.update`
This commit is contained in:
parent
0e8665554b
commit
dd3c0fa3fd
@ -266,6 +266,8 @@ class Morsel(dict):
|
||||
"samesite" : "SameSite",
|
||||
}
|
||||
|
||||
_reserved_defaults = dict.fromkeys(_reserved, "")
|
||||
|
||||
_flags = {'secure', 'httponly'}
|
||||
|
||||
def __init__(self):
|
||||
@ -273,8 +275,7 @@ class Morsel(dict):
|
||||
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)
|
||||
|
||||
@property
|
||||
def key(self):
|
||||
|
@ -0,0 +1 @@
|
||||
Improved performances of creating :py:class:`~http.cookies.Morsel` objects by a factor of 3.8x.
|
Loading…
Reference in New Issue
Block a user