05-Python intermediate

Deepcopy and shallow copy, Value equality vs identity

# Topic covered
* Deepcopy and Shallow copy
* Value equality vs identity

Deepcopy and Shallow copy

  • In case of shallow copy, a reference of object is copied in other object.
    • It means that any changes made to the copied object do reflect in the original object
    • External object id changes but Internal object id remains same
  • In case of deep copy, a copy of object is copied in other object.
    • It means that any changes made to the copied object do not reflect in the original object
    • External and internal object ids changes
[Read More]

Python intermediate | 03-Type Checking

Type Checking/Annotations in Python

Type Checking/Annotations in Python

  • Type Annotations are a new feature added in PEP 484 that allow for adding type hints to variables.
  • They are used to inform someone reading the code what the type of a variable should be.
  • This brings a sense of statically typed control to the dynamically typed Python
  • Usage
    • Annotate Argument
    • Annotate Return type
    • Annotate Variable
[Read More]