Rule and Custom Filter efficiency imbalance

The Pedigree gramplet generates a list of ancestors 12 generations deep, segmented by generation almost immediately. Yet the “Ancestor of <person> not more than <N> generations away” Rule is quite slow in comparison

The following Custom Filter with 2 rules that must apply takes 5.15s to apply in the Person category for a Tree containing 50K people. Applied in the Pedigree chart, it takes 52.84 seconds. (And it repeatedly throws up this oddly dark mode warning dialog… every 6 seconds or less… if you tell it you select the Wait button.)
image

Can Filters be made to run more efficiently in Charts?

Limiting scope to <N> generations of Direct Ancestors (or Direct Descendants) of the Home Person (or Active Person, or set of Person, or a Family) is something that is used very, very frequently.

It there there a highly efficient reusable snippet or Gramps method that we can use for this task?

If not can whatever method the built-in Pedigree gramplet is using seems efficient. Perhaps its method could be added to the Relationship Calculator class? (And leverage its “Max Generations” Limits preference.)