I'm have been a long time user of python, and have recently picked up C++, but really bothers me is that in c++ you can only store integers up to a certain number (2147483647). How are variables stored and computed in python, because there is no limit to variables in python?
How are variables stored in python?
Collapse
X
-
Tags: None
-
It's magic (just kidding). High level languages like Python provide a great deal of "abstractio n", which means that we don't have to think about things like memory locations and the number of bytes used to represent a certain variable type. Low level languages like C require more brain power, more care WRT memory allocation, etc and as much as 10 times more lines of code for a given task.Originally posted by MuffinthiefI'm have been a long time user of python, and have recently picked up C++, but really bothers me is that in c++ you can only store integers up to a certain number (2147483647). How are variables stored and computed in python, because there is no limit to variables in python?
Yes; learn C. It's good for low level software like drivers. Program your apps in Python (and don't worry about how variables are stored [I could tell you, but...])! -
That answers my question perfectly! (Sarcasm)Originally posted by bartoncIt's magic (just kidding). High level languages like Python provide a great deal of "abstractio n", which means that we don't have to think about things like memory locations and the number of bytes used to represent a certain variable type. Low level languages like C require more brain power, more care WRT memory allocation, etc and as much as 10 times more lines of code for a given task.
Yes; learn C. It's good for low level software like drivers. Program your apps in Python (and don't worry about how variables are stored [I could tell you, but...])!Comment
-
While I have no idea how variables are stored internally with Python, I will pass on an assignment that I had in college that helped me understand how it could be done.Originally posted by MuffinthiefI'm have been a long time user of python, and have recently picked up C++, but really bothers me is that in c++ you can only store integers up to a certain number (2147483647). How are variables stored and computed in python, because there is no limit to variables in python?
The assignment was to design a class called LongInteger, which essentially allowed us to store an integer of any size, while preserving the basic arithmetic and boolean operators, and allowing us to write and read LongInteger values from user input.Comment
-
On this same note, take a look at the article I posted yesterday in the Python Articles section. It contains an implementation for long integers which could easily be ported to C++.Originally posted by MotomaWhile I have no idea how variables are stored internally with Python, I will pass on an assignment that I had in college that helped me understand how it could be done.
The assignment was to design a class called LongInteger, which essentially allowed us to store an integer of any size, while preserving the basic arithmetic and boolean operators, and allowing us to write and read LongInteger values from user input.Comment
Comment