Commit 1d93cc8
committed
ensure_type: cache the type adaptors
for a much more efficient type checking of complex types (using pydantic) at runtime:
before:
124 μs ± 82.5 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
after:
1.81 μs ± 4.74 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
for comparison, when using isinstance:
629 ns ± 9.26 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
Signed-off-by: Gaëtan Lehmann <[email protected]>1 parent 203fc77 commit 1d93cc8
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
0 commit comments