[Python-Dev] Meta-reflections (original) (raw)

Kevin Jacobs jacobs@penguin.theopalgroup.com
Thu, 21 Feb 2002 09:10:54 -0500 (EST)


On Thu, 21 Feb 2002, Moore, Paul wrote:

Hmm. I tend to favour "do it right, then do it fast". If there's a performance hit on dir(), why can't it be made faster? [snip] Of course, we really want vars() here, as we're otherwise doing work in dir() to get entries that we then throw away.

dir(object) simply doesn't do what we want. I've tried several times to write a correct pickler using dir(object) and have always run into problems due to pathological corner-cases. I encourage you to try your hand at it.

In the process I've found another issue with the slots implementation. I'll post the details to python-dev in a separate e-mail.

> Note that it does an unnecessary getattr, hasattr, memory > allocation and incurs loop overhead on every dict attribute, > but otherwise it should work once vars is fixed.

Efficiency again. I'd have to bow to your greater experience here. Although with pickling, doesn't I/O usually outweigh any performance cost?

I can't speak for everyone's applications, but we frequently pickle to memory or to the operating system buffer-cache don't live long enough to hit the disk.

Thanks, -Kevin

-- Kevin Jacobs The OPAL Group - Enterprise Systems Architect Voice: (216) 986-0710 x 19 E-mail: jacobs@theopalgroup.com Fax: (216) 986-0714 WWW: http://www.theopalgroup.com