Ideas for extensions of dol -- namely when we will re-architecture it #24
thorwhalen
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Include hooks
Example:
filt_iter
What I really wish for is a way to control the way that
filter(filt, iterable)
will work via the iterable.That way, when there's a different, perhaps more optimized way, to apply
filt
to theiterable
, we can use that.For example, say you want express your
filt
to be a mongo query that will be sent to the remote DB to filter the items closer to the data. That's much less wasteful than asking for the items to be sent one by one over the wire, only to filter out most of them!But there's apparently no way to control builtin
filter
from an iterable (that same way, for example, that you can control whatiter
orlen
does, via the__iter__
and__len__
methods of the iterable.That said, we can control what we wrote: Namely
filt_iter
. We can tell it to first see if the wrapped mapping has a_filter_
method, and if so, pass the job on to it.Beta Was this translation helpful? Give feedback.
All reactions