2010/4/30 Olemis Lang (Simelix) <olemis...@gmail.com>:
[...]
> {{{
> #!python
>
> subconjunto_claves = ['nombre', 'apellidos']
> dic_resultante = dict([k, v] for k, v in d.iteritems() if k in
> subconjunto_claves)
> }}}

%timeit dict((k, d[k]) for k in subkeys)
100000 loops, best of 3: 6.99 µs per loop

%timeit dict([k, v] for k, v in d.iteritems() if k in subkeys)
100000 loops, best of 3: 13.3 µs per loop

~Rolando
_______________________________________________
Python-es mailing list
Python-es@python.org
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/

Responder a