Code review comment for lp:~seif/zeitgeist/add_cache_for_get_events

Revision history for this message
Seif Lotfy (seif) wrote :

OK I don't think Markus said its not a linear search.
I also asked in the python channel and

----
<seiflotfy> is it a linear search to find the item i want to remove
<papna> seiflotfy: Yes.
<seiflotfy> whoa
<papna> seiflotfy: Also, don't use list.remove
<papna> seiflotfy: Decribe your data.
<seiflotfy> i am implementing an lru cache
<seiflotfy> basically a list of ids in a list
<seiflotfy> then i remove a key when its used
<seiflotfy> and append it to the end of the list
<nosklo> seiflotfy: dict
<seiflotfy> yeah
<seiflotfy> i will sill have to go through the dict
<seiflotfy> ot change the value of each key
<seiflotfy> which is still a linear seach AFAIK
<papna> seiflotfy: Yeah, a list isn't appropriate for that.
* zobbo (~ian@88.211.55.77) has joined #python
<papna> seiflotfy: One approach is to keep a linked list and a dict.
<seiflotfy> papna, i did
<seiflotfy> but the list approach was faster
<papna> seiflotfy:
http://bitbucket.org/mikegraham/remember/src/af922eac912c/remember/dicts.py#cl-138
<seiflotfy> papna, i can show u 2 code smaples
<papna> seiflotfy: For realistic n, sure.
-----
I implemented his proposal. And in real life it my list solution is 2x
faster at mimimum.

On Tue, Dec 7, 2010 at 3:37 PM, Seif Lotfy <email address hidden> wrote:

> Guys I reworked it.
> If I recall properly I think Markus said its ok like this, since its not a
> linear search. I am not sure but please reconsider since it really brings a
> big improvement to the table.
> --
>
> https://code.launchpad.net/~seif/zeitgeist/add_cache_for_get_events/+merge/42327
> You are the owner of lp:~seif/zeitgeist/add_cache_for_get_events.
>

--
This is me doing some advertisement for my blog http://seilo.geekyogre.com

« Back to merge proposal