Skip to content

Refactor "_get_next" to not use recursion#6

Merged
georgistanev merged 6 commits intomasterfrom
feature/optimize_get_next
Mar 2, 2026
Merged

Refactor "_get_next" to not use recursion#6
georgistanev merged 6 commits intomasterfrom
feature/optimize_get_next

Conversation

@georgistanev
Copy link
Contributor

@georgistanev georgistanev commented Mar 2, 2026

The recursive method was quite slow with large workflows. This PR tries to change to an iterative approach without changing the functionality.
Version bumped so dependents can reference the new version of the library.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors Flow._get_next to avoid recursion (improving performance and preventing deep-recursion overhead) while preserving task-selection behavior across chained and composite workflows.

Changes:

  • Replaced recursive _get_next traversal with an explicit stack-based (iterative) traversal.
  • Added a dedicated test module covering _get_next behavior across simple chains and composite task scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
taskflow/flow.py Converts _get_next from recursive traversal to an iterative stack-based traversal using deque.
taskflow/test/test_flow_get_next.py Adds expanded test coverage for _get_next across many state combinations and workflow shapes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

georgistanev and others added 2 commits March 2, 2026 10:28
comment updates

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI commented Mar 2, 2026

@georgistanev I've opened a new pull request, #7, to work on those changes. Once the pull request is ready, I'll request review from you.

@georgistanev georgistanev merged commit f5da43e into master Mar 2, 2026
7 checks passed
@georgistanev georgistanev deleted the feature/optimize_get_next branch March 2, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants