469,603 Members | 2,069 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

misguiding docs in 2.3's UserDict ?

I've recently used UserDict's DictMixin class, and I've found the docs
are (somewhat) misguiding: it says, amongst other things, that if my
class implements __contains__ some efficiency will be gained; however,
looking at the source I see that what I should do is implement
has_key, as in DictMixin __contains__ is implemented in terms of
has_key and not viceversa, and if I only implement __contains__,
has_key will still set up a try/except and actually attempt to get at
the key (an operation that might be significantly more expensive than
just checking for existance).

Or did I miss something?

--
John Lenton (jl*****@gmail.com) -- Random fortune:
bash: fortune: command not found
Jul 18 '05 #1
0 1118

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Michele Simionato | last post: by
8 posts views Thread by Uwe Mayer | last post: by
8 posts views Thread by Steven Bethard | last post: by
40 posts views Thread by Xah Lee | last post: by
6 posts views Thread by Joe Cosby | last post: by
1 post views Thread by 帅猛 | last post: by
90 posts views Thread by Christoph Zwerschke | last post: by
12 posts views Thread by Alan Isaac | last post: by
12 posts views Thread by 7stud | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.