Level 9 : What is the difference between a shallow copy and a deep copy in Python?

Author: IndraD | Tags: copy | 1859+ Python FAQs | Share
overflow | lists | list-mutation | match | methods | logical-operation | loop | statement | method | loops | thread-safe-data-structures-(queue.queue) | string-formatting | single-inheritance | membership-operators-(in,-not-in) | string-method | string-slicing | list-comprehension | sets | regular-expressions | list,-set,-and-dictionary-comprehensions | logical-operator | slice | join | indentation | map-function | aggregating-data-with-functools.reduce() | round | sum-function | exception | append | memory-management | key-value-pairs | call | directory-operations | shallow-copy | literal-characters-and-special-characters | bitwise-operator | lambda | iterable | string | string-manipulation | handling-missing-values-(fillna,-dropna) | recursion | command-line-parsing | built-in-modules | syntax | swapping | sorted | access-modifier | keyword | benefit | static-method | integer | center | logical-operators | split | array | string-method | memory | round-function | functional-programming | floats | for | docstring | filter-function | min-function | import-method | lambda-function | mapping-function | attribute | implementation | class-decorators | asyncio | logical-operator | mysql | classes | expand-tab | choice | else | function | async | list-vs-tuple | error | loop-control-statements | syntax-error | generator | invalid-list | syntax-error | expression | immutability | data_structure | sorting | feature | conditional-statements | min-max-function | assignment-operators | bitwise | managing-directories-with-os-and-shutil | assert | string-methods | introduction-to-multiprocessing | string-slicing | sys | else-statement | sorting-and-ranking | list-indexing | mutable | global | sum() | formatting-with-strftime | encoding | multiple-inheritance | sys-module | multiple-except-blocks | integers | data-structures | name-mangling | binary-operation | datatype | global-variable | rollback | math | loop-control | anchors-(^,-$) | identity-operator | binary | global-keyword | list-slicing | counter | lambdas | mathematics | copy | arithmetic-operation | filter | matplotlib | using-lists-as-stacks | set | reading:-read(),-readline(),-readlines() | conditional-statement | matrix | type_conversion | class | asyncio-module | matrix-list-comprehension | list-operation | recurssion | operators | slicing | mathematical-function | booleans | numpy | built-in-function | inheritance | math-copysign | working-with-dates-and-times | functional-programming | comment | postfix | enumerate() | default-mutable-argument | class-and-instance-variable | multiple-inheritance | list-methods-and-slicing | typeerror | package-management | multiprocessing | version | stack | strings | string-formatting | regex | function-argument | method-overloading | gil | arbitrary-arguments-(*args,-**kwargs) | string-concatenation | writing:-write(),-writelines() | function-and-scope | raise-statement | return-statement | list | encapsulation | string-iteration | namedtuple | operator-and | operations | while-else-loop | regular-expression | __init_subclass__ | list-method | software-design | pass | exponentiation | decorator | test-discovery | boolean-and-non-boolean | joining-and-merging-dataframes | threading | numeric | debugging | input | while-loop | creating-custom-modules | module | filtering-and-indexing | compute | iterators | magic-method | file | class-and-inheritance | multithreading | scientific-notation | list-comprehension | operand | input-function | type-conversion | global-variable | identity-operators-(is,-is-not) | generators | complex-number | max-min | unit-testing | design-principle | type-conversion-and-casting | higher-order-function | input-function | exception-handling | lambda-functions | deep-copy | __future__ | datetime | data-type-conversions | immutable-data-type | format | frozenset | formal-and-actual-parameter | basic | overriding-methods | decimal | identifier | built-in | version-check | precedence | set-operation | staticmethod | syntaxerror | file-handling | zip-function | functions | with-statement | random-function | collections | objects | using-os-and-pathlib-modules | working-with-temporary-files-using-tempfile | using-the-threading-module | python-django | indexing | thread-synchronization | python-repl | data-structure | time-series-with-pandas | pickling--unpickling | tuple-unpacking | pandas | zip | data-type | object-attribute | list-join | interpreter | introduction-to-threads | generators-in-python | dataframe-and-series-objects | nested-loop | while-loops | default-arguments | pep | library | bitwise-operator | python-syntax-and-structure | data-types | odd-number | variable | control-statement | operator-overloading | print-statement | comparison | indexing:-loc-vs-iloc | virtual-environment | error-handling | factorial-function | head-and-tail | print | walking-through-directories-using-os.walk() | python-module | reading-and-writing-files | file-handling | difference-between-threads-and-processes | turtle | opening-files-(open()) | touples | advanced-file-operations | exception-handling | operator | tuple | __all__-attribute | why-use-multiprocessing-over-threading?-(gil) | descriptors | def | error-handling | pseudocode | int | thread | collection | oops | fabs-function | list-comprehensions | arithmetic-expression | yield | context-manager | tuple-methods | class-and-object | quantifiers-(*,-+,-?,-{}) | introduction-to-python | parameter | while-and-for-loop | update | built-in-function | id-function | application | namespace | iterator | comprehension | dictionary-comprehensions | inherit | escape-operator | heap-memory | using-join()-and-is_alive()-methods | destructor | assignment-operator | floating-point-precision | using-map()-for-transformations | using-yield-in-functions | python | datetime.date,-datetime.time,-datetime.datetime | python-history | complex | intering | boolean | init | working-with-file-paths | polymorphism | dictionary | file_handling | tuples | dicts | virtual-environment | boolean-masking | data-structures-in-python | zfill-function | using-else-and-finally | operator-or | parsing-with-strptime | goto-function | identity-operator | installation | data-structure | reading-and-writing-large-files-efficiently | dictionary-methods | control-flow | data-type | oop | defining-functions | precedence-and-associativity | python_version | raise | working-with-binary-files-(rb,-wb) | type-conversion | conditional-statement | control-flow | random | creating-and-starting-threads | constructor | counter-function | conversion | python-operators | dictionaries | range | using-assertions-(assertequal,-assertraises) | condition ...