I tried write a python formula with VBA as a workaround to bypass this issue, based on the information here https://support.microsoft.com/en-us/office/py-function-31d1c523-fb13-46ab-96a4-d1a90a9e512f With the idea to create/update objects with a small macro then import the objects in python scripts.
But I couldn't, excel raise a 1004 error which is raised when I forgot to use local formating. Not sure it helps but I think the issue lies ahead of the xl() function.