Self optimizing iterable
python at mrabarnett.plus.com
Fri Jul 17 20:54:22 EDT 2009
Zac Burns wrote:
> I would like a set like object that when iterated maintains a count of
> where iteration stopped and then re-orders itself based on that count
> so that the iteration stopped on the most bubble to the top.
> An example use case for this would be for something like a large table
> of regular expressions that would be iterated over trying to match in
> some string. If some regular expressions are more statistically more
> successful then the iteration will generally be short.
> Does anyone know of a pre-existing recipe for this or feel like taking
> on the challenge?
> Bonus points for:
> Best possible BigO notation on switching order and iteration
> Extend to also include a mapping version
That's not a set, but a Most Recently Used list.
More information about the Python-list