perf: Make frappe._dict great again (#28824)
* perf: Restore dict's flat overrides Using `super()` is unnecessary cost. This class is used A LOT. Ref: https://github.com/frappe/frappe/pull/16449/ Please consider performance while adding types, it's almost always possible to achieve good typing without this. Also `frappe._dict` is almost always used as `dict[Any, Any]` or `dict[str, Any]`, type annotations are useless here. * ci: ugh wait for processes to exit
This commit is contained in:
parent
7dd15e3613
commit
004990e53e
2 changed files with 7 additions and 13 deletions
2
.github/workflows/_base-migration.yml
vendored
2
.github/workflows/_base-migration.yml
vendored
|
|
@ -104,7 +104,7 @@ jobs:
|
|||
if pgrep honcho > /dev/null; then
|
||||
echo "Stopping honcho process..."
|
||||
pgrep honcho | xargs kill
|
||||
sleep 5
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
echo "Setting up environment..."
|
||||
|
|
|
|||
|
|
@ -16,19 +16,13 @@ class _dict(dict[_KT, _VT]):
|
|||
|
||||
__slots__ = ()
|
||||
|
||||
def __getattr__(self, k: str) -> _VT | None:
|
||||
return super().get(k) # type: ignore[arg-type]
|
||||
# NOTE(perf): Do NOT use super() here, it's an unnecessary function call!
|
||||
# Refer: https://github.com/frappe/frappe/pull/16449
|
||||
|
||||
@override
|
||||
def __setattr__(self, k: str, v: _VT) -> None:
|
||||
return super().__setitem__(k, v) # type: ignore[index]
|
||||
|
||||
@override
|
||||
def __delattr__(self, k: str):
|
||||
return super().__delitem__(k) # type: ignore[arg-type]
|
||||
|
||||
def __setstate__(self, m: Mapping[_KT, _VT]) -> None:
|
||||
return super().update(m)
|
||||
__getattr__ = dict.get
|
||||
__setattr__ = dict.__setitem__
|
||||
__delattr__ = dict.__delitem__
|
||||
__setstate__ = dict.update
|
||||
|
||||
@override
|
||||
def __getstate__(self) -> Self:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue