Skip to content
Snippets Groups Projects

worker.py improvements

Merged Manuel Jacob requested to merge topic/default/worker-improvements into branch/default
  1. May 21, 2022
    • Manuel Jacob's avatar
      worker: implement _blockingreader.readinto() (issue6444) · 520722523955
      Manuel Jacob authored
      The core logic for readinto() was already implemented in read(), so this is
      mostly extracting that code into its own method.
      
      Another fix for issue6444 was committed to the stable branch: 2fe4efaa59af.
      That is a minimal fix that implements readinto() only on Python versions that
      require readinto() (3.8.0 and 3.8.1), which is the right approach for the
      stable branch. However, I think that this changeset has its value. It improves
      performance in cases when pickle can use readinto(), it reduces code
      duplication compared to the other patch, and by defining readinto() on all
      Python versions, it makes behavior more consistent across all Python versions.
      This changesets reverts the other change.
      520722523955
    • Manuel Jacob's avatar
      worker: stop relying on garbage collection to release memoryview · 4c57ce494a4e
      Manuel Jacob authored
      On CPython, before resizing the bytearray, all memoryviews referencing it must
      be released. Before this change, we ensured that all references to them were
      deleted. On CPython, this was enough to set the reference count to zero, which
      results in garbage collecting and releasing them.
      
      On PyPy, releasing the memoryviews is not necessary because they are implemented
      differently. If it would be necessary however, ensuring that all references are
      deleted would not be suffient because PyPy doesn’t use reference counting.
      
      By using with statements that take care of releasing the memoryviews, we ensure
      that the bytearray is resizable without relying on implementation details. So
      while this doesn’t fix any observable bug, it increases compatiblity with other
      and future Python implementations.
      4c57ce494a4e
    • Manuel Jacob's avatar
      worker: add docstring to _blockingreader · 4d42a5fb70bf
      Manuel Jacob authored
      4d42a5fb70bf
    • Manuel Jacob's avatar
      5d28246b9acc
Loading