object internals in python
play

Object Internals in Python - Mridu Bhatnagar Who am I? - Python - PowerPoint PPT Presentation

Object Internals in Python - Mridu Bhatnagar Who am I? - Python Enthusiast - Backend Developer by profession. - I love speaking at various meetup groups and conferences. - Twitter handle - @Mridu__ - objects - memory address Learning -


  1. Object Internals in Python - Mridu Bhatnagar

  2. Who am I? - Python Enthusiast - Backend Developer by profession. - I love speaking at various meetup groups and conferences. - Twitter handle - @Mridu__

  3. - objects - memory address Learning - type of objects (mutable Objectives and immutable objects) - difference between is vs == operator - optimizations

  4. An object is an entity that has attribute and methods associated with it.

  5. Example:

  6. The location where the object gets stored in memory is referred to as memory address.

  7. Pictorial Representation

  8. id(object) - id is a built-in function. It is used to determine the memory address of the object.

  9. Mutable objects and Immutable objects.

  10. Objects of built-in type (list, dictionary, sets) are mutable.

  11. Objects of built-in type (int, float, bool, str, tuple) are immutable .

  12. Difference between is vs == operator

  13. Different use cases to discuss memory optimization in Python

  14. 1. Sort and Sorted built-in methods

  15. 2. Concept of Integer Caching

  16. 3. Concept of String Interning

  17. As the Python code compiles identifiers are interned. - variable names - function names - class names Rule: * start with _ or a letter. * may contain _, letter, numbers.

  18. 4. Copying List using Assignment operator

  19. 5. Shallow Copy in Lists

  20. The outermost container is duplicated, but the copy is filled with references to the same items held by the original container.

  21. 6. Deep Copy in Lists

  22. Duplicates do not share references of embedded objects.

  23. Why is it important to learn object internals?

  24. * operator copies the memory references

  25. - object internals - memory address use cases - type of objects (mutable, Summary immutable) - difference between is vs == operator - optimizations

Recommend


More recommend