Skip to content

doc: Replace grass.script by grass.tools #6111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 31, 2025

Conversation

wenzeslaus
Copy link
Member

@wenzeslaus wenzeslaus commented Jul 25, 2025

Replaces grass.script run_command calls by grass.tools in the main documentation. This will eventually include wording about the stability of the API.

old new
image image

@github-actions github-actions bot added Python Related code is in Python libraries docs markdown Related to markdown, markdown files labels Jul 25, 2025
@echoix
Copy link
Member

echoix commented Jul 25, 2025

I have a general question here. Do we have an idea of the performance difference between both usages? Maybe hard to evaluate, but it will be one of the most used code paths at one point

@wenzeslaus
Copy link
Member Author

Performance: Just from the code analysis, there will be only a small difference at this point. Something goes to the attribute lookup and then to the StringIO identification. There will be more if we add, and by default enable, some of the other features, especially the pack IO adds extra cost.

Anyway, at this point, there is no significant difference:

$ grass ~/grassdata/nc_spm_08_grass7/PERMANENT/ --exec python -m timeit -n 100 -c "import grass.script as gs; gs.read_command('g.region', flags='p')"
100 loops, best of 5: 32.1 msec per loop
$ grass ~/grassdata/nc_spm_08_grass7/PERMANENT/ --exec python -m timeit -n 100 -c "from grass.tools import Tools; tools = Tools(); tools.g_region(flags='p').text"
100 loops, best of 5: 32 msec per loop

@wenzeslaus wenzeslaus force-pushed the add-tools-to-main-doc branch from 145b6a3 to 0282091 Compare July 27, 2025 08:04
@wenzeslaus wenzeslaus marked this pull request as ready for review July 27, 2025 08:04
Copy link
Member

@echoix echoix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used a spell check software after noticing a couple odd places.

@echoix echoix requested a review from veroandreo July 27, 2025 12:00
Replaces grass.script run_command calls by grass.tools in the main documentation. This will eventually include wording about the stability of the API.
@wenzeslaus wenzeslaus force-pushed the add-tools-to-main-doc branch from 0282091 to dba20c5 Compare July 28, 2025 12:03
Copy link
Member

@echoix echoix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Letting you finalize the commit message

@wenzeslaus wenzeslaus merged commit 1fe9918 into OSGeo:main Jul 31, 2025
27 checks passed
@wenzeslaus wenzeslaus deleted the add-tools-to-main-doc branch July 31, 2025 07:37
@github-actions github-actions bot added this to the 8.5.0 milestone Jul 31, 2025
@wenzeslaus wenzeslaus removed the request for review from veroandreo July 31, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs libraries markdown Related to markdown, markdown files Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants