Skip to content

Instantly share code, notes, and snippets.

@dobrokot
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dobrokot/7416c65c557fd8260176 to your computer and use it in GitHub Desktop.
Save dobrokot/7416c65c557fd8260176 to your computer and use it in GitHub Desktop.
python tuple/named type memory test
from collections import namedtuple
import numpy
Point = namedtuple('Point', ['x', 'y'])
class Point2:
def __init__(self, x, y):
self.x = x
self.y = y
def main():
test = 6
ts = []
x_numbers = []
y_numbers = []
for i in xrange(1000*1000):
if test == 1:
ts.append(Point(i, i+1));
if test == 2:
ts.append((i, i+1));
if test == 3:
ts.append({"x":i, "y": i+1});
if test == 4:
ts.append(Point2(i, i+1));
if test == 5:
x_numbers.append(i);
y_numbers.append(i+1);
if test == 6:
np_array = numpy.zeros(shape=(1000*1000, 2), dtype='int64')
np_array[999999][1]
raw_input("press Enter...")
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment