A Python developer discovered that the default `ensure_ascii=True` setting in Python's `json.dumps` function significantly increased token usage and reduced accuracy when used in LLM prompts. Unlike JavaScript's `JSON.stringify`, `json.dumps` with this default setting converts non-ASCII characters into hexadecimal escape sequences. This caused Claude to misinterpret Japanese customer names and increased input tokens by 24% on average for a 2,000-ticket dataset. The fix involves setting `ensure_ascii=False` in `json.dumps` and related functions like pandas' `to_json`. AI
IMPACT Default settings in programming libraries can have significant, unforeseen impacts on LLM token usage and accuracy.
RANK_REASON Developer discovers a common programming library's default behavior negatively impacts LLM prompt processing.
AI-generated summary · Google Gemini · from 1 sources. How we write summaries →