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

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