OSGeo / grass

GRASS GIS - free and open-source geospatial processing engine
https://grass.osgeo.org
Other
791 stars 288 forks source link

style(temporal): Sort and group imports #3959

Closed echoix closed 2 days ago

echoix commented 2 days ago

Uses a combination of ruff check --output-format=concise --select I --fix 'temporal/' 'python/grass/temporal', isort --profile=black temporal python/grass/temporal and black .

I separated the big __init__.py as I want to make sure that there aren't any side effects when importing (for python code, it shouldn't have some, but by seeing the state of some of the files, I wouldn't be surprised if there were some finally).

Also, especially for the temporal framework, the big big __init__.py means that everything there is "shortcut-ed" to be available in the scope when importing grass.temporal. I'm not ready to accuse this of being the cause of temporal being slow, but during my last weekend's exploration on trying to profile some temporal tests, after fixing the big slowdown inside one loop of the ply library (that took 18% of the whole time), a big chunk of the remaining time was for importing, at least for t.rast.algebra. So cleaning up the imports and importing what is needed in the files needed (avoiding star imports) might help a little.