Re: My mail configuration

Subject: Re: My mail configuration

Date: Fri, 18 Mar 2011 08:32:36 -0400

To: Jesse Rosenthal, notmuch

Cc:

From: Ben Gamari


On Fri, 18 Mar 2011 03:31:59 -0400, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:
> > # Freeze new messages
> > q_new = notmuch.Query(db, 'tag:new')
> > n_msgs = 0
> > for msg in q_new.search_messages():
> >         msg.freeze()
> >         n_msgs += 1
> 
> It seems like every time you iterate over `q_new.search_messages()', you
> run a new search on tag:new. So at the end, when you thaw the messages,
> you're running that search again, from scratch:
> 
Ouch, yes, you are absolutely right. Thankfully, as you noted, notmuch
seems to be cleaning up after me when I exit.

> > # Tag remaining new items for inbox
> > tag_search(db, 'tag:new', '+inbox', '-new')
> > 
> > # Thaw new messages
> > for msg in q_new.search_messages():
> >         msg.thaw()
> 
> But there are no longer and "tag:new"s, so there shouldn't be any
> results for `q_new.search_messages()', should there? It seems like
> it's thawing 0 messages. Playing around with it, it doesn't seem to make
> a difference, so perhaps thawing is unneccessary if you're exiting after
> tagging. Or am I misunderstanding something?
> 
> By the way, my understanding of the bindings is that you can avoid
> running the new searches by dumping a Messages object into a list. So,
> you can do something like:
> 
>     new_msg_obj = q_new.search_messages()
>     new_msg_list = [m for m in new_msg_obj]
> 
> and then deal with the list from there on out. Not sure if that would
> buy you much performance over running the query repeatedly, but it
> couldn't hurt, and it would seem closer to the effect that you're aiming
> at (since the members of the list would be set from the first query, and
> therefore you'd be thawing the same elements you froze in the first
> place).
> 
This is true, although I'd be worried about memory usage when there are
many new messages. I suppose this probably won't be a problem, however,
and even in the worst case it would probably only be a few hundred
MB. I'll consider this.

Thanks for your note!

Cheers,

- Ben

Thread: