-
Notifications
You must be signed in to change notification settings - Fork 1.7k
optimize frozen dict get item #6021
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
Conversation
CodSpeed Performance ReportMerging #6021 will not alter performanceComparing Summary
|
Greptile OverviewGreptile SummaryOptimized
Confidence Score: 1/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant RouterData
participant HeaderData
participant FrozenDict as _FrozenDictStrStr
participant MappingProxy as MappingProxyType
Client->>RouterData: from_router_data(router_data)
RouterData->>HeaderData: from_router_data(router_data)
HeaderData->>FrozenDict: __init__(**headers)
FrozenDict->>FrozenDict: sort headers dict
FrozenDict->>MappingProxy: wrap in MappingProxyType
Note over FrozenDict,MappingProxy: Old: stored as tuple<br/>New: stored as MappingProxyType
Client->>FrozenDict: __getitem__(key)
Note over FrozenDict: Old: dict(self._data)[key] - O(n)<br/>New: self._data[key] - O(1)
FrozenDict-->>Client: value
Client->>HeaderData: dataclasses.asdict()
HeaderData->>FrozenDict: process as dataclass
FrozenDict->>MappingProxy: copy.deepcopy(_data)
MappingProxy-->>FrozenDict: TypeError: cannot pickle mappingproxy
FrozenDict-->>Client: Error!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
found by @HO-9
this is not a vuln because granian/uvicorn impose a max header count of 100-130