◐ Shell
clean mode source ↗

Message 175998 - Python tracker

Personally I don't like the use of macros inn this code. I think that without them the code would be clearer.

If anyone is interested, here are the statistics for all the standard modules (Lib/__pycache__/*.pyc).

UNICODE         105248  61%
TUPLE            33193  19%
STRING           13527  7.8%
INT               7373  4.3%
CODE              6438  3.7%
NONE              5291  3.1%
TRUE               474  0.27%
FALSE              401  0.23%
BINARY_FLOAT       340  0.2%
LONG                60  0.035%
FROZENSET           20  0.012%

Strings (unicode and bytes), tuples, short ints, code objects and None in sum are 99% of all objects. Mutable collections, complex numbers, Ellipsis and StopIteration are not used at all.

If size of compiled modules is a problem, we can get about 10% by using more compact representation for sizes (1- or 2-bytes). This requires additional codes for strings and collections (at least for unicode strings and tuples).