python linklist pointer and size
<p>I am a rookie python programmer. I see the leetcode's definition of a linked list below. I got 2 questions for this concept, any help would be appreciated. Thanks in advance</p>

<pre><code># Definition for singly-linked list.
# class ListNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.next = None
</code></pre>

<p>Q1 Just wonder what is the type of the "self.next", I know in C++, it should be a pointer that represents the address of the next node. But python does not have that type, so I am confused what type "next" is.</p>

<p>Q2 Some tell me next is just a name. If that is the case, I run the code below, </p>

<pre><code>head =ListNode(1)
print sys.getsizeof(head)
head.next = ListNode(2)
print sys.getsizeof(head)
</code></pre>

<p>first the head.next is 'None', and then it is assigned to another ListNode type,
but I get the same size of head before and after this change, which I think the size of head should be larger since one of its member (next) is changed from None type to ListNode type.  I am just confused about this, thank you so much!</p>

<p>PS. In my understanding, if I keep adding new nodes to the linklist, the head will be larger and larger since there are more and more 'nested' member 'next', just point out where I get wrong, thanks.</p>

<p>My interpretation of a linked list. </p>

<pre><code>class LinkedList(object):
    class Node(object):
        def __init__(self, val=None, next=None, previous=None):
            self.val = val
            self.next = next
            self.last = previous

    def __init__(self):
        self.length = 0
        self.start = None
        self.end = None

    def append(self, value):
        self.length += 1
        if not self.start:
            self.start = self.Node(value)
        else:
            if not self.end:
                self.end = self.Node(value)
                self.end.previous = self.start
                self.end.next = self.start
                self.start.next = self.end
            else:
                end = self.Node(value)
                self.end.next = end
                end.previous = self.end
                self.end = end
                self.end.next = self.start

    def prepend(self, value):
        self.length += 1
        if not self.start:
            self.start = self.Node(value)
        else:
            n = self.Node(value, self.start, self.end)
            self.start.previous = n
            self.start = n

    def __len__(self):
        return self.length

    def __iter__(self):
        self.position = 0
        return self

    def next(self):
        self.position += 1
        if self.position-1 &gt;= len(self):
            raise StopIteration
        if self.position-1 == 0:
            return self.start
        cnt = 0
        n = self.start
        while cnt&lt;self.position-1:
            n = n.next
            cnt += 1
        return n


    def __getitem__(self, index):
        if index == 0:
            return self.start

        if index == -1:
            return self.end

        cnt = 0
        n = self.start
        while cnt&lt;index+1:
            n = n.next
            cnt += 1
        return n.val

    def __repr__(self):
        return repr(tuple(x.val for x in self))

l = LinkedList()
l.append(4)
l.append(5)
l.append(3)
l.prepend(0)
print l
print l[1]
</code></pre>

python c++ class pointers linked-list