Can you tell me how to adjust to support python2 for autoslot ?
I have a lot of python2 object initialization, resulting in a large memory, file modification and upgrading python3 is a big move for me, so I am looking for automatic generation of slots, but I did not find a suitable method. Can you tell me how autoslot supports python2? Because the dis library is too different
I apologise for missing your question! I only saw it now.
The basic design of autoslot is to scan the byte code of the __init__ method of a class and detect assignments to attributes of the object (self). This work is actually done in a metaclass, because doing so allows the metaclass to set the __slots__ field during class creation. (The purposes of metaclass is to modify the behaviour of class construction).
The code of autoslot is quite short, so perhaps you can figure out it out just be reading the code, and modifying the detected bytecode operations to detect assignment.