Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6087 > unrolled thread
| Started by | kracekumar ramaraju <kracethekingmaker@gmail.com> |
|---|---|
| First post | 2011-05-23 11:55 -0700 |
| Last post | 2011-05-24 00:03 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
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? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-24 00:03 +0000
| From | kracekumar ramaraju <kracethekingmaker@gmail.com> |
|---|---|
| Date | 2011-05-23 11:55 -0700 |
| Subject | Re: Is there a better way to solve this? |
| Message-ID | <mailman.1983.1306176915.9059.python-list@python.org> |
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]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2011-05-24 00:03 +0000 |
| Message-ID | <4ddaf5c4$0$29996$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #6087 |
On Mon, 23 May 2011 11:55:08 -0700, kracekumar ramaraju wrote: > You can use sizeof function, Who are you talking to, and what question did they ask? Please always quote enough of the post that you are replying to to establish context. >>>> a=12234 >>>> b=23456.8 >>>> a.__sizeof__() > 12 >>>> b.__sizeof__() > 16 > So sizeof int is 12 bytes and float is 16 bytes You shouldn't be calling special methods directly (except under unusual circumstances). That's like calling s.__len__() instead of len(s). The public function for getting the size of an object is in the sys module: sys.getsizeof(a) -- Steven
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web