[BangPypers] Reorder Dictionary Size in python

Anand Chitipothu anandology at gmail.com
Wed Apr 17 17:35:49 CEST 2013


dictionaries are unordered. It is not a good idea to expect any order in
dictionaries, even if you are seeing some order by chance.

If you need order, then use OrderedDict from collections module (new in
Python 2.7).

Anand


On Wed, Apr 17, 2013 at 9:00 PM, Rahul R <rahul8590 at gmail.com> wrote:

> Hey  Guys,
>
> Is it possible to forcibly reorder the python dictionary after "n" number
> of inserts and deletions. As far as i know, python dictionary performs lazy
> deletes. Thus , even if the data is deleted, python has a dummy data their
> in order to preserve consistency. The python dictionary
> keeps expanding when the size of dict is increasing, but after deleting a
> few parameters the size does not decrease. Is there a way , where I can
> forcibly resize the dictionary ?
>
> I was thinking of copying content from existing dictionary to new dict and
> deleting the previous one.But thats a cumbersome operation.
>
> Thanks,
> ./Rahul
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
Anand
http://anandology.com/


More information about the BangPypers mailing list