[Python-Dev] PyDict_SetItem hook

"Martin v. Löwis" martin at v.loewis.de
Fri Apr 3 18:21:27 CEST 2009


> I think it's worse to give the poor guy the run around
> by making him run lots of random benchmarks.

"the poor guy" works for Wingware (a company you may have
heard of) and has contributed to Python at several occasions.
His name is John Ehresmann.

> In the end, someone will run a timeit or have a specific
> case that shows the full effect.  All of the respondents so far seem to
> have a clear intuition that hook is right in the middle of a critical
> path.  Their intuition matches what I learned by spending a month 
> trying to find ways to optimize dictionaries.

Ok, so add me as a respondent who thinks that this deserves to be
added despite being in the critical path. I doubt it will be noticeable
in practice.

> Am surprised that there has been no discussion of why this should be in
> the default build (as opposed to a compile time option).

Because, as a compile time option, it will be useless. It's not targeted
for people who want to work on the Python VM (who are the primary users
of compile time options), but for people developing Python applications.

> AFAICT, users have not previously requested a hook like this.

That's because debugging Python in general is in a sad state (which, in
turn, is because you can get very far with just print calls).

> Also, there has been no discussion for an overall strategy
> for monitoring containers in general.  Lists and tuples will
> both defy this approach because there is so much code
> that accesses the arrays directly. 

Dicts are special because they are used to implement namespaces.
Watchpoints is an incredibly useful debugging aid.

> Am not sure whether the
> setitem hook would work for other implementations either.

I can't see why it shouldn't.

> If my thoughts on the subject bug you, I'll happily
> withdraw from the thread.  I don't aspire to be a
> source of negativity.  I just happen to think this proposal isn't a good
> idea.

As somebody who has worked a lot on performance, I'm puzzled how
easily you judge a the performance impact of a patch without having
seen any benchmarks. If I have learned anything about performance, it
is this: never guess the performance aspects of code without
benchmarking.

Regards,
Martin


More information about the Python-Dev mailing list