Commit a375344
committed
fix: Relocate custom-option ids to a contiguous block, not by old-id value
create_custom_trees relocated an object's existing custom-option trees to
new ids computed as old_id + offset + 1, where offset is one above the
store's current maximum id. When the object already held the store's
largest id -- the normal case when re-styling the retained result of a
previous .opts() call -- the new id was roughly twice the maximum, so the
maximum id doubled on every re-customization and grew exponentially.
Ids are opaque keys into Store._custom_options; their absolute value
carries no meaning. The relocation only needs new ids disjoint from
existing keys and a bijection over the object's own id set. Assigning a
fresh contiguous block above the offset (indexed by position) satisfies
both and keeps the maximum id linear in the number of live customizations,
avoiding the unbounded bignum growth and the Python 3.11 4300-digit
integer-to-string ValueError it eventually triggered.1 parent cb93307 commit a375344
1 file changed
Lines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1754 | 1754 | | |
1755 | 1755 | | |
1756 | 1756 | | |
1757 | | - | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
1758 | 1765 | | |
1759 | 1766 | | |
1760 | 1767 | | |
1761 | 1768 | | |
1762 | 1769 | | |
1763 | | - | |
1764 | | - | |
1765 | 1770 | | |
1766 | 1771 | | |
1767 | | - | |
1768 | | - | |
| 1772 | + | |
| 1773 | + | |
1769 | 1774 | | |
1770 | 1775 | | |
1771 | 1776 | | |
| |||
0 commit comments