Opened 2 years ago

Closed 2 years ago

#6099 enhancement closed fixed (fixed)

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

Reported by: itamar Owned by: itamar
Priority: normal Milestone: Python 3.3 Minimal
Component: core Keywords:
Cc: Branch: branches/buffer-py3-6099
(diff, github, buildbot, log)
Author: itamarst Launchpad Bug:

Description

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

Change History (5)

comment:1 Changed 2 years ago by exarkun

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 2 years ago by itamarst

  • Author set to itamarst
  • Branch set to branches/buffer-py3-6099

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

comment:3 Changed 2 years ago by itamar

  • Keywords review added
  • Owner changed from itamar to exarkun

http://buildbot.twistedmatrix.com/boxes-supported?branch=/branches/buffer-py3-6099 is running.

Note that the argument names were based on the Python 2 buffer() argument names - http://docs.python.org/library/functions.html#buffer

comment:4 Changed 2 years ago by exarkun

  • Keywords review removed
  • Owner changed from exarkun to itamar

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 2 years ago by itamarst

  • Resolution set to fixed
  • Status changed from new to closed

(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.