Commit 36b5367
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 eba2403 commit 36b5367
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
| 90 | + | |
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
| |||
0 commit comments