- Back to Home »
- Learn Python , Tutorials »
- Learn Python-Class 3: Python And Computer Memory
Posted by : Unknown
Tuesday, 20 August 2013
In this Class lets see what actually is computer memory and how python deals with it.And don't worry in case you feel a bit uncomfortable with this topic,you can safely skip it,but just go through the summary
You can think of Computer memory as boxes,lots and lots of boxes which can store things in the form of binary data.and each box has a name which is called as "the Memory Address".Each box is capable of containing either a one or a zero nothing else ( Every thing is converted into a series of ones and zeros ).these tiny units of memory are called bits.and 8 bits make up a byte and 1024 bytes make a Kilo Byte
1 Bit = Binary Digit
8 Bits = 1 Byte
1024 Bytes = 1 Kilobyte
1024 Kilobytes = 1 Megabyte
1024 Megabytes = 1 Gigabyte
1024 Gigabytes = 1 Terabyte
1024 Terabytes = 1 Petabyte
1024 Petabytes = 1 Exabyte
1024 Exabytes = 1 Zettabyte
1024 Zettabytes = 1 Yottabyte
1024 Yottabytes = 1 Brontobyte
1024 Brontobytes = 1 Geopbyte
And each data item be it an integer a float or any other occupies a number of bytes.
int – occupies 2 bytes(16-bit compiler) or 4 bytes (32-bit compiler) of memory
float - occupies 4 bytes of memory
double – occupies 8 bytes of memory
char – occupies 1 byte of memory
Memory Address:
Memory address is generally represented with a pre fix of x like x102 represents the memory block with address 102 similarly x563,x784 etc
we generally use variables to keep track of the memory addresses.A variable can be considered as a named location or memory cell which can contain different data at different instances,hence it is called a variable.
Python keeps variables in a separate list from values. A variable will contain a memory address, and that memory address contains the value. The variable then refers to the value.Python picks up the available memory addresses for you.so you need not worry about allocating memory addresses. Infact you are no allowed to choose into what memory address your data goes
Terminology
A value has a memory address.A variable contains a memory address.
A variable refers to a value.
A variable points to a value.
Summary:
Computer memory is a long list of storage locations each with a specific address.
Variables are a way to keep track of values stored in computer memory. A variable is a named location in computer memory. Python keeps variables in a separate list from values. A variable will contain a memory address, and that memory address contains the value. The variable then refers to the value. Python will pick the memory addresses for you.