Update a page with Python API unpublished Changes or always changed

Hello community,
I have a problem with updating pages via REST API. As the title suggests I am using the atlassian-python-api library. This works very well.
At the moment I fetch the current content, modify it (if confluence unrelated stuff changed) and update the page with the new content.
But if I update a Page with a code-macro on it I run in either one of these situations and both are not great:

  1. Unpublished Changes:
    The Page remains in an unpublished changed state.
    There are two solutions I found:
    a: that removing the ac:marco-id filed fixes this error
    b: go into edit mode and save again in browser
  2. Content differs
    Everytime I work around issue 1. with solution a: The content of the page is different and I get a page “update”. Even tho I didn’t really changed anything which fills up my Page History with “untrue” changes
    Solution 1.b: is also not viable because there will be alot of pages and penging changes are really not a desired state to be in and will confuse many people.

My Question know is:
What is the correct way to work around this?

Additional Information:
I convert the page[“body”][“storage”][“value”] into an BeautifulSoup Object use the tags and structure of the class to update parts of the page and parse this Object back to the update_page() method of the atlassian-python-api as a string for the parameter body=str(BeautifulSoup object)