Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: clean up text accumulator helpers #31

Closed

Conversation

erlend-aasland
Copy link

@erlend-aasland erlend-aasland commented Dec 21, 2023

Something like this could improve things. I got rid of the named tuples and made TextAccumulator a class with similar members: a pair of add() and out() members, and a pair of append() and output() aliases, in order to easily convert the existing code (and more importantly, to keep the diff friendly). I kept the API of text_accumulator().

Copy link

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice! Part of me wants to rip out the TextAccumulator API completely -- it feels like an unnecessary micro-optimisation that adds a maintenance burden and probably doesn't even make things any faster anymore. That's difficult to do completely, though, because the BufferSeries class depends on it so completely.

Still, I think we could maybe change some of these uses of TextAccumulator to simple "\n".join(foo for foo in bar) calls -- I think it would reduce indirection and make the code easier to understand

@erlend-aasland
Copy link
Author

I think BufferSeries would be easier to comprehend if we just used a list and join.

@erlend-aasland
Copy link
Author

Superseded by #33 (upstream: python#113402)

@erlend-aasland erlend-aasland deleted the clinic/accumulator branch December 22, 2023 12:35
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.

2 participants