Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.05; 'sys': 0.05; 'bytes.': 0.07; 'itself,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'after,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'resize': 0.16; 'structure.': 0.16; 'wrote:': 0.17; 'memory': 0.18; 'import': 0.21; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'question': 0.27; 'header:X-Complaints-To:1': 0.28; "d'aprano": 0.29; 'obj': 0.29; 'steven': 0.29; 'gets': 0.32; 'allocated': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'pm,': 0.35; 'there': 0.35; 'received:org': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'back': 0.62; '10000': 0.65; '2013': 0.84; 'object:': 0.84; 'received:186': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Fabian von Romberg Subject: Re: io.BytesIO Date: Mon, 25 Mar 2013 00:10:04 -0500 References: <514fd6d3$0$29998$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 186.68.114.214 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <514fd6d3$0$29998$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364188221 news.xs4all.nl 6859 [2001:888:2000:d::a6]:44785 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41814 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(10000), it will resize the buffer to 10000 bytes. So my question is how to get those 10000 back from an attribute or method? Regards, Fabian On 03/24/2013 11:47 PM, Steven D'Aprano wrote: > 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 object itself, including any > overhead? > >