Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 16th, 2004, 05:45 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Memory allocation.

Hi,
I wanted to know how much memory is set aside for each data type...or the "objects" rather? Like in C/C++, 'int' took up 4 bytes...'char' 2 bytes and so on....I just wanted to know abt Python objects....that also includes lists, tuples, dictionaries, etc.


Thanks,
Subha

Reply With Quote
  #2  
Old November 16th, 2004, 06:28 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,243 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 5 h 41 m 59 sec
Reputation Power: 265
Use The Source, Luke

There is no simple answer to the question, since it will vary depending on the OS and C compiler, as well as the flags that Python was compiled with.

However you can find all the information you need by looking at the C header files, which should be in an 'include' directory in your Python installation. The place to start is "object.h" which defines the C structs that represent the main Python types.

Good Luck.

Dave - The Developers' Coach

Reply With Quote
  #3  
Old November 18th, 2004, 12:10 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Thanks Dave!
I was searching thru' the net and this piece caught my eye... thought I wld share it with the Python ppl....

Memory sizes of built-in datatypes----------->

Integer ...............:12 bytes
Long Integer.........:12 bytes + (nbits/16 + 1)*2 bytes
Floats..................:16 bytes
Complex...............:24 bytes
List.....................:16 bytes + 4 bytes for each item
Tuple...................:16 bytes + 4 bytes for each item
String..................:20 bytes + 1 byte per character
Dictionary.............:24 bytes + 12*2n bytes, n=log2(nitems) + 1



Rgds,
Subha

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Memory allocation.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT