Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d9f38bc

Browse files
committed
asynchat speedup improvement: avoid to use a function mimicking old buffer() builtin behavior; instead use plain slicing
1 parent a0e3feb commit d9f38bc

1 file changed

Lines changed: 1 addition & 13 deletions

File tree

Lib/asynchat.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,6 @@
4949
import asyncore
5050
from collections import deque
5151

52-
def buffer(obj, start=None, stop=None):
53-
# if memoryview objects gain slicing semantics,
54-
# this function will change for the better
55-
# memoryview used for the TypeError
56-
memoryview(obj)
57-
if start == None:
58-
start = 0
59-
if stop == None:
60-
stop = len(obj)
61-
x = obj[start:stop]
62-
## print("buffer type is: %s"%(type(x),))
63-
return x
6452

6553
class async_chat (asyncore.dispatcher):
6654
"""This is an abstract class. You must derive from this class, and add
@@ -240,7 +228,7 @@ def initiate_send(self):
240228
# handle classic producer behavior
241229
obs = self.ac_out_buffer_size
242230
try:
243-
data = buffer(first, 0, obs)
231+
data = first[:obs]
244232
except TypeError:
245233
data = first.more()
246234
if data:

0 commit comments

Comments
 (0)