Batching - Show a label's first text 3x faster - #240
Merged
Merged
Conversation
A label asked the font for one glyph at a time, so each new character read the font on its own and ran gc.collect(). Load the text's glyphs in one pass first, as adafruit#85 did before it was dropped along with the "M" glyph load in adafruit#102 and adafruit#110. The font is given each character once and never "\n". PCF and LVGL fonts load a repeated character again when handed a string, and a BDF font reads the whole file looking for a newline glyph, on every update before adafruit_bitmap_font 2.4.3. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
makermelissa
approved these changes
Sep 30, 2026
makermelissa
left a comment
Contributor
There was a problem hiding this comment.
Thanks, looks good.
adafruit-adabot
pushed a commit
to adafruit/Adafruit_CircuitPython_Bundle
that referenced
this pull request
Oct 2, 2026
Updating https://github.com/adafruit/Adafruit_CircuitPython_TLV320 to 1.4.0 from 1.3.2: > Merge pull request adafruit/Adafruit_CircuitPython_TLV320#16 from FoamyGuy/support_32000_sample_rate Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 5.0.6 from 5.0.5: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#240 from mikeysklar/label-batch-glyphs Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_Moonshine_Klatt, Adafruit_CircuitPython_PicoTTS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Batching - A label asks the font for all of its letters at once, not one at a time.
Video
Why
Each new letter cost a font read and a garbage collection. #85 fixed this; #102 and #110 accidentally dropped it.
Measured
Font rows: one
label.Label, 44 characters, newly loaded font, median of 10 runs.Tested
Raspberry Pi 5 and Pi Zero 2 W with Blinka, Python 3.13.5. Not tested on a CircuitPython board.
labelandbitmap_labelterminalio.FONT, which has noload_glyphsScope
Repeated letters and newlines are not sent to the font. TextBox is unchanged.
AI assistance
Written with Claude Code.