Kaydet (Commit) d9f38bc7 authored tarafından Giampaolo Rodola''s avatar Giampaolo Rodola'

asynchat speedup improvement: avoid to use a function mimicking old buffer()…

asynchat speedup improvement: avoid to use a function mimicking old buffer() builtin behavior; instead use plain slicing
üst a0e3febe
...@@ -49,18 +49,6 @@ import socket ...@@ -49,18 +49,6 @@ import socket
import asyncore import asyncore
from collections import deque from collections import deque
def buffer(obj, start=None, stop=None):
# if memoryview objects gain slicing semantics,
# this function will change for the better
# memoryview used for the TypeError
memoryview(obj)
if start == None:
start = 0
if stop == None:
stop = len(obj)
x = obj[start:stop]
## print("buffer type is: %s"%(type(x),))
return x
class async_chat (asyncore.dispatcher): class async_chat (asyncore.dispatcher):
"""This is an abstract class. You must derive from this class, and add """This is an abstract class. You must derive from this class, and add
...@@ -240,7 +228,7 @@ class async_chat (asyncore.dispatcher): ...@@ -240,7 +228,7 @@ class async_chat (asyncore.dispatcher):
# handle classic producer behavior # handle classic producer behavior
obs = self.ac_out_buffer_size obs = self.ac_out_buffer_size
try: try:
data = buffer(first, 0, obs) data = first[:obs]
except TypeError: except TypeError:
data = first.more() data = first.more()
if data: if data:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment