This is interesting. During my summer of code project I implemented a
datatype we use in xmms2 called a PropDict in javascript. PropDict
allows us to specifiy the source of a property in a dict/object. In
python it's expressed with the key as (source, key), but this was not
possible with javascript so instead i entirely reformatted the dict to
look something like this:
PropDict={"comment":[{"source":"plugins/mad","value":""}],"album_id":[{"source":"plugins/id3v2","value":"07f3a906-2ad7-491e-a5e3-4a16c6077d28"}],"genre":[{"source":"plugins/mad","value":"Unknown"}],"duration":[{"source":"plugins/mad","value":312090}],"album_front_thumbnail":[{"source":"client/generic/arturl_unverified","value":"http://a1.phobos.apple.com/Music/y2005/m08/d19/h03/mzi.lvlojcan.100x100-99.jpg"}],"lmod":[{"source":"plugins/file","value":1138594707}],"id":[{"source":"server","value":77}],"size":[{"source":"plugins/id3v2","value":7490174},{"source":"plugins/file","value":7491584}],"album":[{"source":"plugins/id3v2","value":"Redemption"},{"source":"plugins/mad","value":"Redemption"}],"laststarted":[{"source":"server","value":1148022656}],"title":[{"source":"plugins/id3v2","value":"Faded
Into One"},{"source":"plugins/mad","value":"Faded Into
One"}],"track_id":[{"source":"plugins/id3v2","value":"e43efbcd-c26e-42d9-abee-f7240f0c3722"}],"artist_id":[{"source":"plugins/id3v2","value":"96cd8ef6-2873-485f-843f-f3ced9839791"}],"resolved":[{"source":"server","value":1}],"added":[{"source":"server","value":1145938852}],"date":[{"source":"plugins/mad","value":"2004"}],"bitrate":[{"source":"plugins/mad","value":192000}],"album_front_small":[{"source":"client/generic/arturl_unverified","value":"http://a1.phobos.apple.com/Music/y2005/m08/d19/h03/mzi.lvlojcan.170x170-99.jpg"}],"artist":[{"source":"plugins/id3v2","value":"Imperative
Reaction"},{"source":"plugins/mad","value":"Imperative
Reaction"}],"url":[{"source":"server","value":"file:///usr/home/alex/music/Imperative_Reaction/Redemption/Imperative+Reaction-Redemption-05-Faded+Into+One.mp3"}],"tracknr":[{"source":"plugins/id3v2","value":5},{"source":"plugins/mad","value":5}],"album_front_large":[{"source":"client/generic/arturl_unverified","value":"http://a1.phobos.apple.com/Music/y2005/m08/d19/h03/mzi.lvlojcan.600x600-100.jpg"}]}
I then implemented a parser for this that added get_value and has_key
methods that supported sources to this dict (all in javascript). I
implemented two versions, one using mochikit and one using my own
implementation of the same things in pure javascript (all made possible
by using SpiderMonkey).
I then wrote a very quick benchmark script (which probably could have
been more detailed and better designed to deal with caching), to test
the speeds of the two implementations and found no significant
difference between the two implementations (I can't remember the
p-value anymore, sorry).
The code and benchmark can be found here:
http://exodus.xmms.se/~alex/benchmark/
A slightly modified version of the MochiKit version that is being used
in TurboX2 now can be found at:
http://git.xmms.se/?p=turbox2.git;a=blob;h=e04f4c40872a0ad4933cb80862409f1de6324eea;hb=a081d20814aa0b28735d1991e6115941bf844d0a;f=turbox2/static/js/turbox2_propdict.js
It may be interesting to consider a few things. First list
comprehensions are available in newest javascript, and it may be
interesting to compare their performance, second perhaps trying with a
foreach loop instead of a C style for loop might offer some interesting
results.
Alex
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---