Skip redundant find_package(Python3) in generator extensions - #266
Open
mjcarroll wants to merge 1 commit into
Open
Skip redundant find_package(Python3) in generator extensions#266mjcarroll wants to merge 1 commit into
mjcarroll wants to merge 1 commit into
Conversation
Every rosidl generator extension calls find_package(Python3 REQUIRED COMPONENTS ...) unconditionally. Because ament_execute_extensions includes each extension into the same scope, a single interface package runs that search once per registered generator -- 13 times for a default rolling workspace. CMake does not memoize this. Each repeat re-enters FindPython/Support.cmake and re-interrogates the interpreter with roughly seven subprocesses. On Windows, where CreateProcess for python.exe costs ~60ms locally and far more on a CI runner, the repeats dominate configure time. Guard each call on the imported target, exactly as ament_cmake_core's python.cmake already does. Imported targets are directory scoped, so the target created by the first search is visible to every later extension. Companion to ros2/rosidl. With all four repos patched, configure of builtin_interfaces drops from 17.6s to 13.1s on Windows (median of 5), python.exe spawns from 92 to 22, and the generated build.ninja is byte identical. Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
mjcarroll
force-pushed
the
guard-redundant-find-package-python3
branch
from
August 23, 2026 01:55
ed8b420 to
b4a110f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to ros2/rosidl#984.