inverting a dictionary of lists

2007-06-14 Thread bpowah
I searched for an hour and don't see a solution to this (i assume
somewhat common) problem.

I have a very large dictionary of lists:
d = {a:[1,2], b:[2,3], c:[3]}
and i want to reverse the associativity of the integers thusly:
inverse(d)   makes   {1:[a], 2:[a,b], 3:[b,c]}

my solution expands the original dict into two lists of keys and list
elements:
list1:  [a,a,b,b,c]
list2:  [1,2,2,3,3]
then recombines them with the reverse operation.

but this takes too much time and a lot of memory.
I wonder if anyone can point me to a more efficient solution?

-- 
http://mail.python.org/mailman/listinfo/python-list


HDR and PIL

2007-09-09 Thread bpowah
I've put together a method (and a script) for rendering (tone mapping)
an arbitrary number of exposures into an HDR-style image.   I really
like the results I'm getting and feel like others could benefit from
it.  I've put together a small write-up here (with the code):

http://bpowah.googlepages.com/hdrandpythonpil

I'd really like to hear comments, suggestions.  Improvements?  Was it
useful?   Should I do anything more with it?

-- 
http://mail.python.org/mailman/listinfo/python-list