Skip to content

Rewrite frame_buffer to use bytearray() #474

Open
@Lukasa

Description

@Lukasa

Good artists copy, great artists steal. One of @njsmith's great decisions with h11 was to write his buffer in terms of bytearray. This has some major efficiency gains on Python 3.4.

An easy win for us would be to rewrite the buffering internals of our frame buffer using h11's, while removing the things that h11's buffer implements that we don't need (in particular, any line-oriented constructs). Before we do it, we should write a benchmark of the buffering performance under reasonable HTTP/2 conditions to see what kind of improvements we see.

While I'm here: @fijal, the comments in h11's framebuffer say:

# Note that starting in Python 3.4, deleting the initial n bytes from a
# bytearray is amortized O(n), thanks to some excellent work by Antoine
# Martin:
#
#     https://bugs.python.org/issue19087

...

# make sure PyPy also has the optimization

Does it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions