For context, i’ve implemented some form of hot-reloading into python, In short the hot-reloader wraps a given python script, it saves the values of the "marked" variables to a file, reloads the wrapped script then loads the values into their corresponding variables.
The problem I have is a quick and sensible way of marking variables to be hot-reloaded. So far I have named variables that start with "_h_", for example :- self._h_pos_x
. Obviously this is extremely poor practice as users will have to rename the variable everywhere, where it is used.
I feel that there is a much faster alternative to this solution that I am clearly missing. I’ve tried other methods such as wrapping a variable value with a given object, but this means the wrapped variable no longer behaves like its original object and causes inaccuracy with type hinting and code completing. Another method I tried was commenting above variables like so:
#HOTSAVE
self.pos_x = self.centerx + self.radius * math.cos(self._h_angle) - self.square_size // 2
Obviously this method was the least sensible although it made switching variables in and out very quick. I would appreciate a range of answers and i’m open to all sorts of alternatives.
You need to sign in to view this answers
Leave feedback about this