[Zope-dev] Re: "hasattr" geddon
Casey Duncan
casey at zope.com
Fri Jul 9 13:50:40 EDT 2004
On Fri, 9 Jul 2004 16:22:17 +0200
Dieter Maurer <dieter at handshake.de> wrote:
[..]
> The "hasattr" replacement in Python's "__builtin__" could look like:
>
> _marker = []
> def hasattr(obj, attr):
> return getattr(obj, attr, _marker) is not _marker
>
>
> Opinions?
+1
Another advantage to a global patch is that 3rd party products (such as
CMF) would benefit automatically. I noticed yesterday some hasattr calls
in DCWorkflow that could cause inaccurate results if the hasattr
returned false due to a ConflictError.
It might be worth profiling this and an alternate implementation in C to
see if the latter is worthwhile. I can't imagine the C implementation
would be all that complex. That would dispense with any performance
disadvantage of the patch.
-Casey
More information about the Zope-Dev
mailing list