Skip to content

Conversation

@devin-ai-integration
Copy link

Summary

This PR replaces the O(n²) bubble sort algorithm in the _sort method with Python's built-in sorted() using functools.cmp_to_key, achieving O(n log n) time complexity. The method is used to order preprocessing labels based on pairwise ordering constraints.

Also includes an efficiency report (EFFICIENCY_REPORT.md) documenting 5 potential efficiency improvements found in the codebase for future reference.

Review & Testing Checklist for Human

  • Verify sorting equivalence: The new comparator logic should produce the same ordering as the original bubble sort. When a + "#" + b is in label_order, a should come before b. Test with actual preprocessing label sets to confirm.
  • Run the test suite: Execute pytest to ensure no regressions in pipeline generation, as this method affects how preprocessing components are ordered.
  • Check edge cases: Verify behavior when neither a#b nor b#a exists in label_order (comparator returns 0). The original bubble sort would preserve relative order; Python's sort is stable but behavior with cmp_to_key should be validated.

Recommended test plan: Run the existing test suite and manually test pipeline generation with a dataset that uses multiple preprocessing steps to verify the ordering is correct.

Notes

Replace O(n^2) bubble sort in _sort method with Python's built-in sorted()
using functools.cmp_to_key for O(n log n) time complexity.

Also includes an efficiency report documenting other potential improvements
in the codebase.

Co-Authored-By: Kosaku Kimura <kimura.kosaku@jp.fujitsu.com>
@devin-ai-integration devin-ai-integration bot requested a review from a team as a code owner December 23, 2025 05:00
@devin-ai-integration devin-ai-integration bot requested review from AkiraUra and kimusaku and removed request for a team December 23, 2025 05:00
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🎉 Thanks for submitting the PR to SapientML!!

Here is the Contribution Guideline.
We would like you to read the document and follow it.
If you have any question or anything to be discussed, please join the Discord server and chat with us.
Thank again!

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.

1 participant