unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Lucas Hoffmann <l-m-h@web.de>
To: l-m-h@web.de,  notmuch@notmuchmail.org
Subject: Re: [PATCH 1/2] python: add bindings for notmuch_database_get_config{, _list}
Date: Tue, 20 Jun 2017 22:06:26 +0200	[thread overview]
Message-ID: <149798918666.30630.17090980439386410942@localhost.localdomain> (raw)
In-Reply-To: <87zidgcd4a.fsf@tethera.net>

[-- Attachment #1: Type: text/plain, Size: 3273 bytes --]

Now I finally found some time to come back to this.

Quoting David Bremner (2017-06-10 13:10:13)
> Thanks for writing these bindings, it will be good to have the bindings
> (almost) catch up to the library again.

My pleasure.

> We generally expect more than just a subject line in the commit message

OK.

> I guess we will eventually want set_config as well, even if it's not
> needed for your immediate application. It might save future confusion to
> add them both at the same time (unless there's something complicated
> about adding set_config).

Done, will send it out the next time I send the patches.

> It would be good to add a couple tests. test/T590-libconfig.sh has some
> C tests. I think the first one, labelled
> "notmuch_database_{set,get}_config" could just be translated into python
> (maybe even replace the C test with the python one, depending what
> others think).

Started it, will also come with the next round.  I would not remove the
C tests.  It could always happen that something is broken with the
python bindings even though the C bindings are fine.

> > +    def get_config_list(self, prefix):
>
> I don't object to the simplified interface, but I would like to know
> what we can do if it becomes a performance bottleneck.  Would it be
> possible to replace building the list with a generator (yield statement)
> without changing client code? or should we take the leap now?

I don't see a reason to have python programmers handle "manual
iterators" or however you want to call the thing the C code does there.
So I would like to keep *some* simplified interface as well.

It is very easy to turn this into a generator.  But then I consider the
name a mismatch.  If it is called "get_config_list" it should return a
list.  I could add get_config_iterator or get_config_generator and turn
get_config_list into a wrapper:

def get_config_list(self, prefix):
    return list(self.get_config_iterator(prefix))

The only problem one could see with this additional entry point is what
you said in id:87wp8kcbvg.fsf@tethera.net about the function
get_all_named_queries (quote below), namely that the names of the python
bindings diverge from the names of the C bindings.  I don't think that
there will be a performance problem as I assume that there will not be
many config values in the database so storing them in memory should not
be a problem.

Quoting David Bremner (Message-ID: <87wp8kcbvg.fsf@tethera.net>)
> I have somewhat mixed feelings about this. I don't really like the
> python bindings diverging from the C library.  It's also not clear it's
> worth supporting a new API entry (since e.g. if this goes in it also
> needs a test) to save the python client one line of code. On the
> positive side I can see there is arguably a missing abstraction on the
> library side, as those particular config items are special.

I think I will drop this commit
(34d9febc53775a24ca9e1bb1abcef64ea9196b12).

If we want to introduce some more abstract interface in python we could
also do this:

def get_configs(self, prefix):
    return dict(self.get_config_iterator(prefix))

(or with a different name like get_config_dict)

Which interface would you prefer?

Lucas

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

-----BEGIN PGP SIGNATURE-----

iQEzBAABCAAdFiEE96z4mcwnF18GSMtNYLcfxwAaQaEFAllJgEIACgkQYLcfxwAa
QaHRYQgApqtnjjTvA2hcu3xfvd+tKGTXv8KDn8yCfWcgrnM92cBJv9oUg0vM8q62
ZC4yZfaw3WzlxubpCLM9goE6rr3yqLs99mHUxPb1bj8P+xoJXSSKfR07uT54zvhZ
vmSTV884duRNo8pVeb5JQuwXEDROqP/R3jAkbBz9OGtjggQZJuMQwfXBPj8I7F8s
rPCebTsdUs41ksYUSuVzBwh2qjL77IRAWZplhKYOXJJxyLjTNoLcYUZ7c/9H3Xkv
EA3cGEv8r8uhw/FxkwuH4Qa4SDLQ22MHtTvlCSQZ4+ecDKkoXuWCyYnZoWPy7Ol/
EgFc8VKpN+plv0Vrt265tjTbNrZ3gQ==
=D00Y
-----END PGP SIGNATURE-----

  reply	other threads:[~2017-06-20 20:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-04 17:20 [PATCH 1/2] python: add bindings for notmuch_database_get_config{, _list} l-m-h
2017-06-04 17:20 ` [PATCH 2/2] python: add convenience function to get named queries l-m-h
2017-06-10 11:37   ` David Bremner
2017-06-10 11:10 ` [PATCH 1/2] python: add bindings for notmuch_database_get_config{, _list} David Bremner
2017-06-20 20:06   ` Lucas Hoffmann [this message]
2017-06-26 23:19     ` David Bremner
2017-12-07 11:40       ` [PATCH 0/6] " l-m-h
2017-12-19 11:13         ` David Bremner
2017-12-07 11:40       ` [PATCH 1/6] python: add bindings to access config l-m-h
2017-12-07 11:40       ` [PATCH 2/6] python: add default arg to get_config_list l-m-h
2017-12-07 11:40       ` [PATCH 3/6] python: turn get_config_list into a generator l-m-h
2017-12-07 11:40       ` [PATCH 4/6] test: Add tests for new python bindings l-m-h
2017-12-07 11:40       ` [PATCH 5/6] python: Rename get_config_list to get_configs l-m-h
2017-12-22 21:59         ` David Bremner
2017-12-22 22:26           ` [PATCH 0/1] " l-m-h
2017-12-22 22:26           ` [PATCH 1/1] python: Fix method name in docs l-m-h
2017-12-24 14:05             ` David Bremner
2017-12-07 11:40       ` [PATCH 6/6] test: Add test to unset config items with the python bindings l-m-h

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=149798918666.30630.17090980439386410942@localhost.localdomain \
    --to=l-m-h@web.de \
    --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).