Commit 35d30e3
committed
fix: use cqltype objects as cache keys instead of id() to prevent GC/reuse issues
id()-based cache keys are unsafe for non-singleton parameterized types
(e.g., ListType(Int32Type)) which are created fresh by apply_parameters().
If such objects are GC'd, Python could reuse the same id() for a different
type, returning the wrong cached Deserializer.
Using the cqltype object itself as the dict key holds a strong reference,
preventing GC and id() reuse. Since cqltypes use default object identity
for __hash__/__eq__, this is semantically equivalent to id()-based keying
but safer. Benchmarks show slightly better performance as well (no id()
call overhead on the cache-hit path).1 parent 74e1d35 commit 35d30e3
1 file changed
Lines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
444 | 447 | | |
445 | 448 | | |
446 | 449 | | |
447 | 450 | | |
448 | | - | |
| 451 | + | |
449 | 452 | | |
450 | 453 | | |
451 | 454 | | |
| |||
457 | 460 | | |
458 | 461 | | |
459 | 462 | | |
460 | | - | |
461 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
462 | 467 | | |
463 | 468 | | |
464 | 469 | | |
465 | 470 | | |
466 | | - | |
467 | 471 | | |
468 | | - | |
| 472 | + | |
469 | 473 | | |
470 | 474 | | |
471 | 475 | | |
| |||
497 | 501 | | |
498 | 502 | | |
499 | 503 | | |
500 | | - | |
| 504 | + | |
501 | 505 | | |
502 | 506 | | |
503 | 507 | | |
| |||
0 commit comments