Analysis of the CPython 3.13 standard library reveals that comments and docstrings constitute approximately 34.8% of tokens, making them the most significant portion of code sent to LLMs. In contrast, whitespace, such as indentation and blank lines, accounts for a much smaller percentage, with indentation saving only 2.5% when reduced. This suggests that efforts to reduce token count for LLM context windows should prioritize stripping prose over whitespace, as the latter offers minimal savings. AI
IMPACT Focusing on prose reduction in code can significantly cut LLM token costs for AI coding assistants.
RANK_REASON Analysis of code tokenization for LLMs. [lever_c_demoted from research: ic=1 ai=1.0]
AI-generated summary · Google Gemini · from 1 sources. How we write summaries →