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

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