reading notes for code fellows
These are some simple concepts for starting out in Python, and as such it is good to get a handle on them before we get into the language and start work on anything that will build off of these concepts.
Big O Notation is used to describe the complexity or performance of an algorithm (as in the execution time or space used) in the worst case scenario.
O(1): an algorithm that will always execute in the same time/space regardless of the data sent in.O(N): an algorithm whose performance will grow in direct proportion to the size of the input data.O(N^2): an algorithm whose performance is directly proportional to the input data squared (common in nested data sets).O(2^N): an algorithm whose growth doubles with each addition to the input data.O(log N): an algorithm using something like a binary search to halve input data sets until the vaule is found or it can no longer continue.Python works a lot like other languages, in that underlying mechanisms are simple, but can have surprising effects.
Names refer to values, and assignment makes a specific name refer to a specific value such as x = 23. Multiple names can refer to a single value, and names are reassigned independantly. Values will continue to exist until their reference value becomes 0.
In Python, assignment never copies data, which means that if two names are assigned to the same data set any changes will appear under either name. (This is otherwise known as mutable aliasing)
Immutable values cannot be changed in place or alias (ints, floats, strings, tuples) When “changes” are referenced in these types, it is more accurately defined as ‘rebinding’.
Names are not the only references, for instance, list elements are each references, and so are object attributes and anything that can appear on the left side of an assignment.
The best way to avoid surprises with values in functions is to create new things rather than mutating values.
In Python, names have no type and values have no scope.
I understand a bit more now about mutable vs immutable values and why some change and others don’t between names, but I still think I need to go a bit more in depth with it to get the concept fully cemented in my head.
The different notations of O are like a lot of different math problems, and they work like a pessimist trying to prepare you for the worst case scenario, while the referential nature of Python as a language is similar to, but slightly different from other languages I have worked with in that, yes, it is not strictly typed, but you need to be strict about the way you are assigning things or else it will all get out of hand.