From: Guido van Rossum Date: Wed, 21 Aug 1996 14:54:28 +0000 (+0000) Subject: More efficient handling of "__doc__" lookup. X-Git-Tag: v1.4b3~71 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=019f424a0a88e97e3df2e83ea6b66aa50943702f;p=thirdparty%2FPython%2Fcpython.git More efficient handling of "__doc__" lookup. --- diff --git a/Objects/classobject.c b/Objects/classobject.c index d7be15a449fa..57768988cd8b 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -43,8 +43,14 @@ newclassobject(bases, dict, name) #endif classobject *op, *dummy; static object *getattrstr, *setattrstr, *delattrstr; - if (dictlookup(dict, "__doc__") == NULL) { - if (dictinsert(dict, "__doc__", None) < 0) + static object *docstr; + if (docstr == NULL) { + docstr= newstringobject("__doc__"); + if (docstr == NULL) + return NULL; + } + if (mappinglookup(dict, docstr) == NULL) { + if (mappinginsert(dict, docstr, None) < 0) return NULL; } if (bases == NULL) {