Re: io.BytesIO

2013-03-25 Thread Fabian von Romberg
Hi Steve, thanks for your reply. Actually I played around with these methods. Whe you truncate(12468) for example, I thought the object would allocate 12468 bytes and I wanted to get that back. The methods your mention, works only for what ha been written (obj.write()). I think I should use

Re: io.BytesIO

2013-03-24 Thread Steven D'Aprano
On Mon, 25 Mar 2013 00:10:04 -0500, Fabian von Romberg wrote: > Hi Steven, > > > actually why I need is to know how much memory has been allocated for > buffering. > > getsizeof gets the size of the object structure. I can see at least four ways to get the current size of the BytesIO buffer:

Re: io.BytesIO

2013-03-24 Thread Fabian von Romberg
Hi Steven, actually why I need is to know how much memory has been allocated for buffering. getsizeof gets the size of the object structure. For example, if I do io.BytesIO.truncate(1), it will resize the buffer to 1 bytes. So my question is how to get those 1 back from an attribu

Re: io.BytesIO

2013-03-24 Thread Steven D'Aprano
On Sun, 24 Mar 2013 22:56:12 -0500, Fabian von Romberg wrote: > Hi, > > is there any way to get the allocated memory size from a io.BytesIO > object? The same as for any object: py> import io, sys py> obj = io.BytesIO() py> sys.getsizeof(obj) 48 Is this what you are after, the size of the obj