Level 9 : What is the purpose of the __slots__ attribute in a Python class?

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