]> granicus.if.org Git - python/commitdiff
asynchat speedup improvement: avoid to use a function mimicking old buffer() builtin...
authorGiampaolo Rodola' <g.rodola@gmail.com>
Sat, 4 Aug 2012 12:38:16 +0000 (14:38 +0200)
committerGiampaolo Rodola' <g.rodola@gmail.com>
Sat, 4 Aug 2012 12:38:16 +0000 (14:38 +0200)
Lib/asynchat.py

index 2199d1b3eff37c42da09767d7ee1f7b939c4881f..4e26bb5856dcf1858881870b87ca14f04b3d76a3 100644 (file)
@@ -49,18 +49,6 @@ import socket
 import asyncore
 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):
     """This is an abstract class.  You must derive from this class, and add
@@ -240,7 +228,7 @@ class async_chat (asyncore.dispatcher):
             # handle classic producer behavior
             obs = self.ac_out_buffer_size
             try:
-                data = buffer(first, 0, obs)
+                data = first[:obs]
             except TypeError:
                 data = first.more()
                 if data: