Commit 4b81afe
committed
perf: replace KeyError exception with dict.get() in BoundStatement.bind()
Replace try/except KeyError with dict.get() + sentinel pattern in the
per-column binding loop of BoundStatement.bind(). This loop runs once
per column per execute() call for dict-style bindings, making it a hot
path. Using dict.get() avoids the overhead of raising and catching
KeyError for every missing/optional column.
The sentinel object (_BIND_SENTINEL) is necessary to distinguish a
missing key from an explicit None value in the bound dict.1 parent 9c53d78 commit 4b81afe
1 file changed
Lines changed: 12 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| |||
608 | 611 | | |
609 | 612 | | |
610 | 613 | | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
620 | 623 | | |
621 | 624 | | |
622 | 625 | | |
| |||
0 commit comments