Zitat von Chris Withers <ch...@simplistix.co.uk>:

a_dict = dict(
    x = 1,
    y = 2,
    z = 3,
    ...
    )

What can we do to speed up the former case?

It should be possible to special-case it. Rather than creating
a new dictionary from scratch, one could try to have the new dictionary
the same size as the original one, and copy all entries.

I also wonder whether the PyArg_ValidateKeywordArguments call is really
necessary: if this is not a proper keyword dictionary, dict creation
could still proceed in a reasonable way.

I don't know how much this would gain, though. You still have to
create two dictionary objects. For a better speedup, try

def xdict(**kwds):
  return kwds

(possibly written in C for even more speed)

Regards,
Martin


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to