People-Places-Solutions / floodmodeller-api

The Flood Modeller Python API is a free and open-source python package which provides a bridge between Flood Modeller and the python programming language to extend the capabilities of Flood Modeller in automated workflows
https://api.floodmodeller.com/api/
Other
38 stars 15 forks source link

Improve performance of inserting many units #96

Closed joe-pierce closed 6 months ago

joe-pierce commented 8 months ago

Currently the DAT.insert_unit() is handy for insert a single unit into a DAT file, and can be called in a loop to add more than one. However when adding larger amounts of units it becomes pretty slow as every iteration requires the DAT._update_raw_data() method to be called.

Instead it would be better to have a new method DAT.insert_units() which can be passed a list of units, and inserts them one by one but defers the _update_raw_data() call until the end. It will need some investigation to check this will work as expected.