speedy Python strings?

Stuart D. Gathman stuart at bmsi.com
Mon Jan 19 22:02:31 EST 2004


On Tue, 20 Jan 2004 01:43:24 +0100, Uwe Mayer wrote:

> class myFile(file):
>         def read(self, *args):
>                 ...
#           self.buffer += file.read(self, *args) # not this
	    self.buffer = self.buffer[self.pos:] + file.read(self, *args)
	    self.pos = 0
>                 ...
> 
> and after reading information from the buffer I remove the read part from
> it:
>         
#         text = struct.unpack("L", self.buffer[:4])
#         self.buffer = self.buffer[4:]
	  pos = self.pos
	  text = struct.unpack("L", self.buffer[pos:pos+4])
	  self.pos = pos + 4

-- 
	      Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.




More information about the Python-list mailing list