Developer measures 42% token cost increase from adding line numbers to code
11/20/2026 — 11/20, 20:19·1 sources (all)·1 reports (all)
Key takeaways
- A developer used tiktoken's o200k_base tokenizer to measure all top-level modules in the Python 3.13 standard library and found that adding…
Background & analysis
On November 20, 2026, the AI section of DEV Community published a hands-on measurement by a developer showing that adding line numbers to code before sending it to an LLM raises token cost. According to the article, the developer used the o200k_base tokenizer from tiktoken and measured every top-level module in the Python 3.13 standard library. The result showed that when each line is prefixed in the format produced by cat -n, the token count of the code portion rises by 42%, which in turn pushes up the cost of APIs that bill per input token.
The article explains why developers reach for this practice in the first place. When building a coding assistant, it is often desirable for the model to point at exact lines, such as saying the bug is on line 212 or that lines 40 to 52 should be replaced. The usual approach is to number every line before pasting the file into the prompt. Writing that step is cheap, since a single enumerate call generates the numbers, but sending the result is not. The author frames the finding as a trade-off that developers need to revisit, weighing the value of precise line references against the extra tokens consumed.
The available reporting consists of this single article, and it stops at the measured result and the recommendation. No vendors, framework maintainers, or API providers have responded, and no follow-up experiments or alternative line-referencing schemes have been reported yet.
AI-generated from 1 reports · updated 2 days ago
- Heat index
- 33
- All sources
- 1
- All reports
- 1
- First seen
- 2 days ago
Reports on this story headlines open the original
A developer measured every top-level module in the Python 3.13 standard library with tiktoken's o200k_base tokenizer and found that adding cat -n style line numbers inflates the code's token count by 42%, directly raising per-token API costs. The post weighs that overhead against the convenience of having a model point at exact lines.
DEV Community · AIAI score 61
Other stories people are talking about
- Heat index 1143RisingAnthropic Reaches $1.6 Trillion Market Value in First Trading Week After IPO21 sources
- Heat index 1011Anthropic Mathematician Says Claude Formalized the Generalized Riemann Hypothesis21 sources
- Heat index 622Anthropic IPO total raise reaches $93.5 billion after greenshoe exercise20 sources
- Heat index 596RisingThinking Machines Lab Open-Sources Inkling 2 Mini with 32GB Model Card Recommendation10 sources
- Heat index 490RisingSEC probes Nvidia accounting practices as shares post seven-week slide9 sources
How is heat calculated?About the methodHide
Heat counts how many independent sources covered a story in the last 48 hours: one source counts once no matter how many posts it published, decaying with a 24-hour half-life. What ranks first is what many people are talking about.
This page aggregates public feeds. Headlines and summaries are machine-organized and remain the property of the original authors; verify important facts at the source. If you believe a headline or summary infringes your rights, email the contact address in the footer with the page URL and basis of your claim, and we will remove or replace it after review.
- Surge
- Discussion rising fast
- New
- First report within 6 hours
- Rising
- Still gathering discussion

