State Savers¶
Different methods to save the state, this allows for more modularity than just having a big switch statement in the main code. Note that these classes are not subclasses of a more generic class, as this allows these classes to save data in a completely different manner from each other. Furthermore, it avoids (slow) inheritance.
- class pypdevs.statesavers.AssignState(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Class to save the state using a simple assignment, is unsafe for most situations…
- __init__(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Constructor
- Parameters
time_last – time_last to save
time_next – time_next to save
state – state to save
activity – the activity of the computation
my_input – the state input to save for memorisation
elapsed – the time elapsed
- __weakref__¶
list of weak references to the object (if defined)
- class pypdevs.statesavers.CopyState(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Class to save the state using the Python ‘copy’ library
- __init__(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Constructor
- Parameters
time_last – time_last to save
time_next – time_next to save
state – state to save
activity – the activity of the computation
my_input – the state input to save for memorisation
elapsed – the time elapsed
- __weakref__¶
list of weak references to the object (if defined)
- class pypdevs.statesavers.CustomState(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Class to save the state using a manually defined copy() function of the state. If no such method is provided, an error is raised.
- __init__(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Constructor
- Parameters
time_last – time_last to save
time_next – time_next to save
state – state to save
activity – the activity of the computation
my_input – the state input to save for memorisation
elapsed – the time elapsed
- __weakref__¶
list of weak references to the object (if defined)
- class pypdevs.statesavers.DeepCopyState(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Class to save the state using the Python ‘deepcopy’ library
- __init__(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Constructor
- Parameters
time_last – time_last to save
time_next – time_next to save
state – state to save
activity – the activity of the computation
my_input – the state input to save for memorisation
elapsed – the time elapsed
- __weakref__¶
list of weak references to the object (if defined)
- class pypdevs.statesavers.MarshalState(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Class to save the state using the Python ‘marshal’ library.
- __init__(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Constructor
- Parameters
time_last – time_last to save
time_next – time_next to save
state – state to save
activity – the activity of the computation
my_input – the state input to save for memorisation
elapsed – the time elapsed
- __weakref__¶
list of weak references to the object (if defined)
- class pypdevs.statesavers.PickleHighestState(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Class to save the state using the Python ‘pickle’ library, with the option to use the highest available pickling protocol.
- __init__(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Constructor
- Parameters
time_last – time_last to save
time_next – time_next to save
state – state to save
activity – the activity of the computation
my_input – the state input to save for memorisation
elapsed – the time elapsed
- __weakref__¶
list of weak references to the object (if defined)
- class pypdevs.statesavers.PickleZeroState(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Class to save the state using the Python ‘pickle’ library, with the option to use the pickling protocol 0.
- __init__(time_last, time_next, state, activity, my_input, elapsed)[source]¶
Constructor
- Parameters
time_last – time_last to save
time_next – time_next to save
state – state to save
activity – the activity of the computation
my_input – the state input to save for memorisation
elapsed – the time elapsed
- __weakref__¶
list of weak references to the object (if defined)