You should be able to use the GraphQL Admin API to retrieve the cost per item of your products via the unitCost field on the InventoryItem object.
You can then use the returned data in your Python program to perform your updates - or use the Bulk Operations API to update. Would this work for your use case?