|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 ![]() |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Memory allocation. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|