Skip to content

aiorepl: Optimize sys.stdout.write calls. - #1148

Merged
dpgeorge merged 1 commit into
micropython:masterfrom
ziesemer:aiorepl/optimize-sys-stdout-write
Aug 17, 2026
Merged

aiorepl: Optimize sys.stdout.write calls.#1148
dpgeorge merged 1 commit into
micropython:masterfrom
ziesemer:aiorepl/optimize-sys-stdout-write

Conversation

@ziesemer

Copy link
Copy Markdown
Contributor

Summary

  • aiorepl.mpy: 3,152 -> 2,955 bytes (-197 bytes, -6.3%)
  • Bump patch version to 0.2.4.

Testing

Tested on RP2.

Generative AI

I did not use generative AI tools when creating this PR.

@ziesemer
ziesemer force-pushed the aiorepl/optimize-sys-stdout-write branch from a6dace9 to a5484e3 Compare August 15, 2026 16:35
@agatti

agatti commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR!

You can maybe pick a more readable name than sw and keep the same output size.

@ziesemer
ziesemer force-pushed the aiorepl/optimize-sys-stdout-write branch from dcec65b to 0c256a9 Compare August 15, 2026 18:09
@ziesemer

Copy link
Copy Markdown
Contributor Author

@agatti - done.

I had tried to follow what was here:

  • s: (StreamReader)
  • c: "ord of most recent character"
  • pc: "previous character"
  • t: "timestamp of most recent character"
  • pt: "previous time"

... with sw as stdout.write. I now renamed this to stdout_write.

Regardless, confirmed - yes, the output size remains the same at 2,955 bytes.

@agatti

agatti commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Thanks!

That naming scheme can work for global entities (eg. classes, functions, variables), arguments in function declarations, and class members. Those names are retained in the MPY file once compiled, but local variable names get discarded when compiled.

@ziesemer

Copy link
Copy Markdown
Contributor Author

That naming scheme can work for global entities (eg. classes, functions, variables), arguments in function declarations, and class members. Those names are retained in the MPY file once compiled, but local variable names get discarded when compiled.

Understood, but everything we're talking about here is all at the same scope. :-) So maybe those should be renamed as well...

@agatti

agatti commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Point taken, then how about write? :)

Oh, and feel free to squash things into one single commit while you're at it.

Still, that's a nice change you've made there - I wonder where else in micropython-lib these modifications can be applied to.

@ziesemer
ziesemer force-pushed the aiorepl/optimize-sys-stdout-write branch from 0c256a9 to cca9257 Compare August 15, 2026 18:37
@ziesemer

Copy link
Copy Markdown
Contributor Author

@agatti - agreed, updated, and squashed.

@agatti

agatti commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Great, thank you!

Comment thread micropython/aiorepl/aiorepl.py Outdated
- aiorepl.mpy: 3,152 -> 2,955 bytes (-197 bytes, -6.3%)
- Bump patch version to 0.2.4.

Signed-off-by: Mark A. Ziesemer <online@mark.ziesemer.com>
@ziesemer
ziesemer force-pushed the aiorepl/optimize-sys-stdout-write branch from cca9257 to df05604 Compare August 17, 2026 12:34
@dpgeorge
dpgeorge merged commit ee4bb8f into micropython:master Aug 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants