Commit afedb11
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 1efb579 commit afedb11
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
88 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
0 commit comments