Use actual bytesarray/memoryview instead of bytes concatenation

Open
#113 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start in fluent/sender.py at line 137 and trace the buffering path around self.pendings. Read the surrounding sender implementation to compare the proposed bytearray or memoryview approach with the current concatenation. Done means buffered sends no longer repeatedly concatenate bytes while preserving the sender's existing behavior.

Written by the indexing model from the issue text.

Description

Bytes concatenation such as this is extremely wasteful and is never a good idea.

https://github.com/fluent/fluent-logger-python/blob/master/fluent/sender.py#L137

        # buffering
        if self.pendings:
            self.pendings += bytes_
            bytes_ = self.pendings

Python has mutable buffers that should be used to ensure that the objects aren't created needlessly putting pressure on GC and wasting CPU with double-copy concatenation.

Dominant language
Python
Stars
457
Forks
138
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fluent/fluent-logger-python

All issues in fluent/fluent-logger-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.