Commit 2bca4f1
committed
Add __slots__ to Token classes and TokenMap for memory optimization
Add __slots__ to frequently instantiated token-related classes to reduce
memory overhead by preventing dynamic attribute creation:
* Token base class with __slots__ = ('value',)
* All Token subclasses (HashToken, Murmur3Token, MD5Token, BytesToken)
with __slots__ = ()
* TokenMap class with comprehensive attribute tuple and consolidated
docstring documentation
These classes are instantiated frequently during cluster metadata parsing
and query planning. The __slots__ optimization prevents Python from
creating __dict__ for each instance, significantly reducing memory usage
especially in large clusters with many tokens.
All existing functionality is preserved and unit tests pass.
Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>1 parent 9b54ce0 commit 2bca4f1
1 file changed
+19
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1729 | 1729 | | |
1730 | 1730 | | |
1731 | 1731 | | |
1732 | | - | |
1733 | 1732 | | |
1734 | | - | |
1735 | | - | |
1736 | | - | |
1737 | | - | |
1738 | | - | |
1739 | | - | |
1740 | | - | |
1741 | | - | |
1742 | | - | |
1743 | | - | |
1744 | | - | |
1745 | | - | |
1746 | | - | |
1747 | | - | |
1748 | | - | |
1749 | | - | |
1750 | | - | |
1751 | | - | |
1752 | | - | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
1753 | 1740 | | |
1754 | 1741 | | |
1755 | | - | |
| 1742 | + | |
| 1743 | + | |
1756 | 1744 | | |
1757 | 1745 | | |
1758 | 1746 | | |
| |||
1815 | 1803 | | |
1816 | 1804 | | |
1817 | 1805 | | |
| 1806 | + | |
| 1807 | + | |
1818 | 1808 | | |
1819 | 1809 | | |
1820 | 1810 | | |
| |||
1854 | 1844 | | |
1855 | 1845 | | |
1856 | 1846 | | |
| 1847 | + | |
| 1848 | + | |
1857 | 1849 | | |
1858 | 1850 | | |
1859 | 1851 | | |
| |||
1866 | 1858 | | |
1867 | 1859 | | |
1868 | 1860 | | |
| 1861 | + | |
| 1862 | + | |
1869 | 1863 | | |
1870 | 1864 | | |
1871 | 1865 | | |
| |||
1884 | 1878 | | |
1885 | 1879 | | |
1886 | 1880 | | |
| 1881 | + | |
| 1882 | + | |
1887 | 1883 | | |
1888 | 1884 | | |
1889 | 1885 | | |
| |||
1896 | 1892 | | |
1897 | 1893 | | |
1898 | 1894 | | |
| 1895 | + | |
| 1896 | + | |
1899 | 1897 | | |
1900 | 1898 | | |
1901 | 1899 | | |
| |||
0 commit comments