Fabian von Romberg
fromberg100 at hotmail.com
Tue Mar 26 03:43:24 CET 2013
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 io.BufferedWriter instead.
Just one question, what has better performance: BufferedWriter or BytesIO?
Thanks and regards,
On 03/25/2013 01:54 AM, Steven D'Aprano wrote:
> 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
>> getsizeof gets the size of the object structure.
> I can see at least four ways to get the current size of the BytesIO
> py> obj = io.BytesIO(b"x"*12468)
> py> obj.getbuffer().nbytes
> py> len(obj.getvalue())
> py> len(obj.getbuffer())
> py> obj.seek(0, 2)
> As far as I can tell, BytesIO objects do not have a fixed size buffer.
> They will increase in size as needed, just like real file objects on a
More information about the Python-list