Questions tagged [slots]

`__slots__` is a python language feature to reduce size of object instances by dropping the builtin dictionary every python instance normally features in order to support dynamic assignment of attributes and replacing it with a fixed set of attributes (the 'slots').

__slots__ is a python language feature to reduce size of object instances by dropping the builtin dictionary every python instance normally features in order to support dynamic assignment of attributes and replacing it with a fixed set of attributes (the 'slots'). See: https://docs.python.org/2/reference/datamodel.html#slots

306 questions
0
votes
2 answers

Dataclass to dict when using slots

If I use a regular dataclass I can get a dict with @dataclass class Cat: fur: bool meow: int Cat(True, 3).__dict__ But it doesn't work when using __slots__. What is the most efficient solution to use instead? @dataclass class Cat: …
v1z3
  • 137
  • 2
  • 9
0
votes
0 answers

Pyqt5 Signals and Slots

I am having trouble creating custom signals and connecting them between classes. Login Class class LoginApp(Ui_Login_Win): switch_window = QtCore.pyqtSignal() def __init__(self): self.window = QtWidgets.QDialog() …
0
votes
1 answer

C# - Worker thread with slots, items being dynamically added

I have window service that polls a web service for new items every 30 seconds. If it finds any new items, it checks to see if they need to be "processed" and then puts them in a list to process. I spawn off different threads to process 5 at a…
Derek
  • 131
  • 1
  • 1
  • 7
0
votes
0 answers

I'm getting an error " returned a result with an error set" when I use __slots__

I'm trying to make a gui with pyqt5. The code works fine when I don't have the varaibales under __slots__ but once I put them in I get an error saying "(built-in function connectSlotsByName) returned a result with an error set" and on the top of the…
Libocado
  • 43
  • 3
0
votes
0 answers

Vuetify Data Table Slots with nested item properties

I'm having a hard time figuring out how to access item properties from within a v-data-table slot with a specific JSON format. The items bound to the v-data-table have a nested property called "technicals" which also contains several nested…
Chris S
  • 17
  • 1
  • 5
0
votes
1 answer

Why does this PyQt5 Qlistwidget signal + slot not working?

I've been trying to make this work, but it just doesn't. I get no errors, just plain noncompliance. It just does not want to add the QListWidget items, or change the QLabel. I made a MainWindowClass. It it's main widget I have a layout and a button.…
user122121
  • 130
  • 6
0
votes
1 answer

How to use descriptors and __slots__ in Python at the same time

I am new to your community. Sorry for my English. I am interested in Python languages. Please help me understand descriptors. I don't know how to use descriptors and _slots_ in class Calendar at the same time. Here is an example of my code: …
0
votes
1 answer

How should I define a __repr__ for a class hierarchy in python?

Given the following code: class Base: __slots__ = 'base_field', def __init__(self, base_field): self.base_field = base_field def __repr__(self): return…
Tim Stewart
  • 5,350
  • 2
  • 30
  • 45
0
votes
1 answer

Event System and Move Semantics in C++

I have recently been messing around with event systems in C++ like boost::signals2 and similar libraries. They all seem to have one limitation in common: they don't really work with move semantics. If you connect your signal to a slot that is a…
Eric
  • 1,183
  • 6
  • 17
0
votes
1 answer

Avoid Pycharm __dict__ lookup when using __getattr__ and __slots__ for composition

Say I have a class: class Example: __slots__ = ("_attrs", "other_value") def __init__(self): self._attrs = OrderedDict() self.other_value = 1 self.attribute = 0 def __setattr__(self, key, value): if…
Alesi Rowland
  • 379
  • 2
  • 16
0
votes
1 answer

Including slots in auto-generated admin modules with Symfony

Is there a way of including a slot from generator.yml in Symfony? I would like to add a piece of HTML code only within some backend modules, and slots is the best idea I can come up with. If not with generator.yml, how can I achieve this? Thanks!
elitalon
  • 9,191
  • 10
  • 50
  • 86
0
votes
1 answer

Staging Slots for Azure Web Apps for Containers are available Only in production Tier - very expensive

I have been developing a React SPA with Python Api using Docker and Azure Web Apps for Containers. Now when I want to develop the production deployment process I find that there are no app service tiers which include slots other than very expensive…
badcop666
  • 121
  • 2
  • 9
0
votes
0 answers

__slots__ does not reduce memory

I have the following class: class DataGenerator(keras.utils.Sequence): __slots__ = 'path','batch_size','dim','mode','split_proportion','indices','processes' def __init__(self, path: str, batch_size: int, …
Daniel
  • 471
  • 3
  • 8
  • 18
0
votes
1 answer

any way of iterating over __slots__ and dynamically assign values?

I'm making a framework for an agent based model and I have a class called agents. Since there's going to be thousands of agents in the simulation, I want to use the __ slots__, which will replace the default __ dict__ and reduce memory consumption.…