Perspective state: what is the best way to save and reload?

I want to be able to save and load Perspective state. I have created a function to grab the state and save them into string format. Is there a better way to do this?
P.S. cannot get my head around state_push and state_pop, hope some one can help me shine some lights on this.

def get_ps_params(ps):
    params = dict(column_pivots = ps.column_pivots, 
                    columns = ps.columns,
                    filters = ps.filters,
                    group_by = ps.group_by,
                    plugin = ps.plugin,
                    row_pivots = ps.row_pivots,
                    sizing_mode = ps.sizing_mode,
                    split_by = ps.split_by,
                    theme = ps.theme,
                    sort = ps.sort,
                    width = ps.width,
                    height = ps.height,
                    computed_columns = ps.computed_columns
    return params

params = {'column_pivots': [],
 'columns': ['Fuel Oil'],
 'filters': [['year', '==', 2022]],
 'group_by': ['Date', 'year', 'month'],
 'plugin': 'd3_y_bar',
 'row_pivots': ['Date', 'year', 'month'],
 'sizing_mode': 'fixed',
 'split_by': [],
 'theme': 'material-dense',
 'sort': None,
 'width': 2000,
 'height': 800}

ps_new = pn.pane.Perspective(df, **params)