Re: [PATCH 0/3] python/notmuch2: a few docstrings and collect_tags()

Subject: Re: [PATCH 0/3] python/notmuch2: a few docstrings and collect_tags()

Date: Tue, 12 Jan 2021 10:13:20 +0100

To: David Bremner, Floris Bruynooghe, notmuch@notmuchmail.org

Cc:

From: Michael J Gruber


Floris Bruynooghe venit, vidit, dixit 2021-01-11 21:47:33:
> On Thu 07 Jan 2021 at 17:09 +0000, Michael J. Gruber wrote:
> > As for the series: the notmuch based MUA "alot" switched to the new
> > python bindings recently. collect_tags() is something I used in a
> > feature PR submitted but not merged yet there (while on the old bindings),
> > and in my updated feature PR there I directly roll
> > notmuch2._tags.ImmutableTagSet(msgs, '_iter_p', notmuch2.capi.lib.notmuch_messages_collect_tags).
> 
> You could do this entirely in the public bindings too could you not?
> Something like (untested):
> 
> def collect_tags(db, query):
>     tags = set()
>     for msg in db.messages(query):
>         tags.update(msg.tags)
> 
> anyway, i guess the internal APIs you use won't change before your
> patchset here lands so this doesn't matter much.

Yes, that gives the same set.

A quick unscientific test on my 80k messages db with 640 different tags
gives for the search string '*':

notmuch search --ouput=tags: < 0.01s (shell's time)
nm2.db.tags (can do '*' only): < 1e-4s
direct roll as quoted above: 0.02s
from public bindings as above: 4.5s
(all py times time.perf_counter, python 2.9)

To be honest, converting the result of the direct roll to a set or list adds 2s.
So, depending on the query and use case, it can be a tremendous
difference or almost unnoticable.

Cheers
Michael
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: