On Oct 18, 9:09 am, Abandoned <[EMAIL PROTECTED]> wrote: > On Oct 18, 6:57 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > > > Abandoned wrote: > > > On Oct 18, 6:35 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > >> Abandoned wrote: > > >> > On Oct 18, 6:14 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > >> >> Abandoned wrote: > > >> >> > Thanks you all answer.. > > >> >> > But "eval" is very slow at very big dictionary {2:3,4:5,6:19....} > > >> >> > (100.000 elements) > > >> >> > Is there any easy alternative ? > > > >> >> How big? How slow? For me, a 10000-element list takes 0.04 seconds to > > >> >> be parsed. Which I find fast. > > > >> >> Diez > > > >> > 173.000 dict elements and it tooks 2.2 seconds this very big time for > > >> > my project > > > >> Where does the data come from? > > > >> Diez > > > > Data come from database.. > > > I want to cache to speed up my system and i save the dictionary to > > > database for speed up but eval is very slow for do this. > > > Not: 2.2 second only eval operation. > > > Does the dictionary change often? > > > And you should store a pickle to the database then. Besides, making a > > database-query of that size (after all, we're talking a few megs here) will > > take a while as well - so are you SURE the 2.2 seconds are a problem? Or is > > it just that you think they are? > > > Diez- Hide quoted text - > > > - Show quoted text - > > I'm very confused :( > I try to explain main problem... > I have a table like this: > id-1 | id-2 | value > 23 24 34 > 56 68 66 > 56 98 32455 > 55 62 655 > 56 28 123 > .... ( 3 millions elements) > > I select where id=56 and 100.000 rows are selecting but this took 2 > second. (very big for my project) > I try cache to speed up this select operation.. > And create a cache table: > id-1 | all > 56 {68:66, 98:32455, 62:655} > > When i select where id 56 i select 1 row and its took 0.09 second but > i must convert text to dictionary.. > > Have you got any idea what can i do this conver operation ? > or > Have you got any idea what can i do cache for this table ?
I think several people have given you the correct answer, but for some reason you aren't getting it. Instead of saving the string representation of a dictionary to the database, pickle the dictionary (not the string representation, but the actual dictionary) and save the pickled object as a BLOB to the database. using pickle to re- create the dictionary should be much faster than evaluating a string representation of it. Matt -- http://mail.python.org/mailman/listinfo/python-list