Copy python

1. list of replication

  • Implemented directly shallow copy of assignments, with both the id () function return value is the same, i.e. occupies the same memory space.
  • Import library copy with copy.deepcopy (list1) by assignment to achieve deep copy, with both the id () function returns the value is different, and each has its own memory space.

Such as:

  2. numpy.array copy

  • Implemented directly shallow copy of assignments, with both the id () function return value is the same, i.e. occupies the same memory space.
  • With arr.copy () re-assignment to achieve deep copy, both with id () function's return value is different, and each has its own memory space.

Such as:

 

Guess you like

Origin www.cnblogs.com/wxiaoli/p/11440018.html