View on GitHub

Ann Molly Paul

learn -- code -- inspire

Facts about python

February 27, 2015

  1. Immutability:
            x=23 
            y=x 
            x=2
    But y is still 23

  2. Memory is managed dynamically,
        x= 'hello'
        x= 'world'
    
    (Values live until reference dies)
    'hello' is cleaned up since it no longer has a reference.
  3. Mutable aliasing Assignment never copies data, it simply creates ref
    a = [1,2] 
    b = a
    
    Only one list exists
    a.append(200) 
    print b  // [1,2,200] 
    

  4. a=257
    b=257 
    a is b //False 
    
    Only if the var was less than 257 then they are True as the compiler stores their address in the same location for efficiency
  5. Names in python have no type [They live on the heap]
  6. Values in python have no scope [They libe on the stack]