Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6086 > unrolled thread

Re: Is there a better way to solve this?

Started bykracekumar ramaraju <kracethekingmaker@gmail.com>
First post2011-05-23 11:55 -0700
Last post2011-05-23 18:06 -0400
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Re: Is there a better way to solve this? kracekumar ramaraju <kracethekingmaker@gmail.com> - 2011-05-23 11:55 -0700
    Re: Is there a better way to solve this? David Robinow <drobinow@gmail.com> - 2011-05-23 16:27 -0400
    Re: Is there a better way to solve this? Terry Reedy <tjreedy@udel.edu> - 2011-05-23 18:06 -0400

#6086 — Re: Is there a better way to solve this?

Fromkracekumar ramaraju <kracethekingmaker@gmail.com>
Date2011-05-23 11:55 -0700
SubjectRe: Is there a better way to solve this?
Message-ID<a6f25b6b-ddfe-435a-9035-5f156888d2b5@glegroupsg2000goo.googlegroups.com>
You can use sizeof function,
>>> a=12234
>>> b=23456.8
>>> a.__sizeof__()
12
>>> b.__sizeof__()
16
So sizeof int is 12 bytes and float is 16 bytes

[toc] | [next] | [standalone]


#6094

FromDavid Robinow <drobinow@gmail.com>
Date2011-05-23 16:27 -0400
Message-ID<mailman.1986.1306182479.9059.python-list@python.org>
In reply to#6086
On Mon, May 23, 2011 at 2:55 PM, kracekumar ramaraju
<kracethekingmaker@gmail.com> wrote:
> You can use sizeof function,
>>>> a=12234
>>>> b=23456.8
>>>> a.__sizeof__()
> 12
>>>> b.__sizeof__()
> 16
> So sizeof int is 12 bytes and float is 16 bytes

I'm not sure what you're trying to show here, but try the following in
Python 3.2

>>> a = 9999
>>> for i in range(5):
...      a*= 100000
...      a.__sizeof__()
...

[toc] | [prev] | [next] | [standalone]


#6097

FromTerry Reedy <tjreedy@udel.edu>
Date2011-05-23 18:06 -0400
Message-ID<mailman.1988.1306189308.9059.python-list@python.org>
In reply to#6086
On 5/23/2011 2:55 PM, kracekumar ramaraju wrote:
> You can use sizeof function,

Appears not to be in manuals, that I could find. As a special method, it 
is intended to be called through sys.getsizeof.

>>>> a=12234
>>>> b=23456.8
>>>> a.__sizeof__()
> 12
>>>> b.__sizeof__()
> 16
> So sizeof int is 12 bytes and float is 16 bytes

Depends on system. On my winxp machine, ints are 14 bytes.

 >>> import sys
 >>> size = sys.getsizeof
 >>> size(1)
14
 >>> size(1.0)
16
 >>> size([])
36
 >>> size([1,2,3])
48

-- 
Terry Jan Reedy

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web