unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Michael J Gruber <git@grubix.eu>
To: David Bremner <david@tethera.net>,
	Floris Bruynooghe <flub@devork.be>,
	notmuch@notmuchmail.org
Subject: Re: [PATCH 0/3] python/notmuch2: a few docstrings and collect_tags()
Date: Tue, 12 Jan 2021 10:13:20 +0100	[thread overview]
Message-ID: <161044280062.3453.13815706143861925195.git@grubix.eu> (raw)
In-Reply-To: <87o8hv42vu.fsf@powell.devork.be>

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

      reply	other threads:[~2021-01-12  9:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06  9:08 [PATCH 0/3] python/notmuch2: a few docstrings and collect_tags() Michael J Gruber
2021-01-06  9:08 ` [PATCH 1/3] python/notmuch2: correct docstring for Database.count_messages() Michael J Gruber
2021-01-06  9:08 ` [PATCH 2/3] python/notmuch2: docstrings for Database.threads(), Database.count_threads() Michael J Gruber
2021-01-06  9:08 ` [PATCH 3/3] python/notmuch2: provide binding for collect_tags() Michael J Gruber
2021-01-11 20:33   ` Floris Bruynooghe
2021-02-11 17:06     ` Michael J Gruber
2021-01-07 14:35 ` [PATCH 0/3] python/notmuch2: a few docstrings and collect_tags() David Bremner
     [not found]   ` <E1kxYme-0002nO-P1@sphinx.mythic-beasts.com>
2021-01-11 20:47     ` Floris Bruynooghe
2021-01-12  9:13       ` Michael J Gruber [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=161044280062.3453.13815706143861925195.git@grubix.eu \
    --to=git@grubix.eu \
    --cc=david@tethera.net \
    --cc=flub@devork.be \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).