From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id WB00Gkpq/V+gLAAA0tVLHw (envelope-from ) for ; Tue, 12 Jan 2021 09:22:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 6MEDFkpq/V+SLQAAB5/wlQ (envelope-from ) for ; Tue, 12 Jan 2021 09:22:18 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A27259403E6 for ; Tue, 12 Jan 2021 09:22:16 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 45DEA29E53; Tue, 12 Jan 2021 04:22:09 -0500 (EST) X-Greylist: delayed 521 seconds by postgrey-1.36 at nmbug; Tue, 12 Jan 2021 04:22:08 EST Received: from mailproxy07.manitu.net (mailproxy07.manitu.net [IPv6:2a00:1828:1000:1112::2]) by mail.notmuchmail.org (Postfix) with ESMTPS id 0F43629DCB for ; Tue, 12 Jan 2021 04:22:08 -0500 (EST) Received: from localhost (200116b860ca3a009bcf3a5981e147fb.dip.versatel-1u1.de [IPv6:2001:16b8:60ca:3a00:9bcf:3a59:81e1:47fb]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: michael@grubix.eu) by mailproxy07.manitu.net (Postfix) with ESMTPSA id 77525C80BD; Tue, 12 Jan 2021 10:13:23 +0100 (CET) MIME-Version: 1.0 In-Reply-To: <87o8hv42vu.fsf@powell.devork.be> References: <87wnwou85n.fsf@tethera.net> <87o8hv42vu.fsf@powell.devork.be> Subject: Re: [PATCH 0/3] python/notmuch2: a few docstrings and collect_tags() From: Michael J Gruber To: David Bremner , Floris Bruynooghe , notmuch@notmuchmail.org Message-ID: <161044280062.3453.13815706143861925195.git@grubix.eu> Date: Tue, 12 Jan 2021 10:13:20 +0100 User-Agent: alot/0.9.1 Message-ID-Hash: NJ4GRLEP7G2VDRFTCDYEERQYPJCDGI3Q X-Message-ID-Hash: NJ4GRLEP7G2VDRFTCDYEERQYPJCDGI3Q X-MailFrom: michael@grubix.eu X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.08 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: A27259403E6 X-Spam-Score: -1.08 X-Migadu-Scanner: scn0.migadu.com X-TUID: eAvhZv7/ysRi 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