03-Python Advance

Deepcopy and shallow copy

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]

04-Python Advance

Value equality vs identity

Value equality vs identity

  • Value –> equivalent contents
  • Identity –> same object

Binding Names to Objects

p = [1,2,3]
q = [1,2,3] 
p == q  # --> True    --> val is same
p is q  # --> False   --> not same obj

a = "first"
b = "first"
a is b # --> True
  • NOTE:
    • Immutable object (str, int tuple) refers to same obj if values are same
    • Mutable obj always create new object

Pass by object reference

  • Python uses neither Pass by Value nor Pass by Reference
  • But it uses Pass by Object Reference
[Read More]

07-Python Advance

Multi-threading in Python

7. Multi-threading

Multithreading allows you to break down an application into multiple sub-tasks and run these tasks simultaneously.

If you use multithreading properly, your application speed, performance, and rendering can all be improved.

Multithreading is defined as the ability of a processor to execute multiple threads concurrently.

[Read More]

08-Python Advance

Multi Processing

Multi Processing

Multiprocessing refers to the ability of a system to support more than one processor at the same time.

Applications in a multiprocessing system are broken to smaller routines that run independently. The operating system allocates these threads to the processors improving performance of the system.

[Read More]