Opened 7 years ago

Closed 7 years ago

#6099 enhancement closed fixed (fixed)

Add buffer()-compatible function for Python 3 to twisted.python.compat

Reported by: Itamar Turner-Trauring Owned by: Itamar Turner-Trauring
Priority: normal Milestone: Python 3.3 Minimal
Component: core Keywords:
Cc: Branch: branches/buffer-py3-6099
branch-diff, diff-cov, branch-cov, buildbot
Author: itamarst


buffer() is used in twisted.internet.tcp, twisted.internet.abstract (and elsewhere: IOCP and We should provide a sufficiently compatible version based on memoryview to meet the requirements of those users.

Change History (5)

comment:1 Changed 7 years ago by Jean-Paul Calderone

But probably not based on memoryview, due to the problems it comes with (complexity, poor documentation, incompatibility with parts of pyOpenSSL, etc).

comment:2 Changed 7 years ago by itamarst

Author: itamarst
Branch: branches/buffer-py3-6099

(In [36118]) Branching to 'buffer-py3-6099'

comment:3 Changed 7 years ago by Itamar Turner-Trauring

Keywords: review added
Owner: changed from Itamar Turner-Trauring to Jean-Paul Calderone is running.

Note that the argument names were based on the Python 2 buffer() argument names -

comment:4 Changed 7 years ago by Jean-Paul Calderone

Keywords: review removed
Owner: changed from Jean-Paul Calderone to Itamar Turner-Trauring

Regarding naming... How about a name that doesn't give the appearance of being more than trivially buffer-compatible - lazyByteSlice or something descriptive like that? The idea behind this being that our requirement is not for a buffer replacement (and this isn't one, since that would be a ton of work), but for a way to slice strings without copying memory unnecessarily. buffer did that for us, but is kind of an implementation detail.

Alternatively (and I think this is worse), be more explicit in documenting the limitations of our buffer.

Otherwise this looks great. Please address the naming point somehow and then merge.

comment:5 Changed 7 years ago by itamarst

Resolution: fixed
Status: newclosed

(In [36128]) Merge buffer-py3-6099.

Author: itamar Review: exarkun Fixes: #6099

Add function to emulate buffer() on both Python 2 and (less efficiently) on Python 3.

Note: See TracTickets for help on using tickets.