We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 53bacb3 commit 817bfbaCopy full SHA for 817bfba
1 file changed
injection/_core/hook.py
@@ -1,4 +1,5 @@
1
import itertools
2
+from collections import deque
3
from collections.abc import Callable, Generator, Iterator
4
from dataclasses import dataclass, field
5
from inspect import isclass, isgeneratorfunction
@@ -13,8 +14,8 @@
13
14
15
@dataclass(eq=False, frozen=True, slots=True)
16
class Hook[**P, T]:
- __functions: list[HookFunction[P, T]] = field(
17
- default_factory=list,
+ __functions: deque[HookFunction[P, T]] = field(
18
+ default_factory=deque,
19
init=False,
20
repr=False,
21
)
@@ -35,7 +36,7 @@ def __stack(self) -> Iterator[HookFunction[P, T]]:
35
36
return iter(self.__functions)
37
38
def add(self, *functions: HookFunction[P, T]) -> Self:
- self.__functions.extend(reversed(functions))
39
+ self.__functions.extendleft(functions)
40
return self
41
42
@classmethod
0 commit comments