
I thinking of extending the __getitem__ hook to accept slice objects
Please have a look at http://sourceforge.net/tracker/?func=detail&aid=459235&group_id=5470&atid=105470 It's a known problem, but Guido won't fix it anytime soon. So I guess contributions are welcome.
As with all optimizations: Patches to just improve the performance are unacceptable unless accompanied by some hard numbers to show that they really do have the desired effect. History shows that patches to just improve the performance may be unacceptable even if accompanied by such numbers. Normally, Tim will construct a scenario where the patch causes a slow-down, and argue that this is a common scenario :-) Regards, Martin

"Martin v. Loewis" wrote:
Good to know, thanks.
Sounds like you have experience ;-) As with all micro-optimizations, the win usually only shows up in some applications. The one I'm writing uses lot's of if tagtype == 'starttag': if tagtype == 'endtag': ... Since the 'starttag' and 'endtag' strings are interned and I'm also interning the strings which are stored in tagtype, I'd like to benefit from the fact that the compare will actually work as 'is'-compare. However, I don't want to use 'is' because I consider interning only an optimization and not a feature of the language. That's why I would like the simple if (v == w) return 0; integrated into the ceval loop right along the INT-compare optimization. This may also help in some other situations where objects are shared. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/

Agreed.
Maybe this could be done as follows: if (v == w && PyString_CheckExact(v)) return 0;
This may also help in some other situations where objects are shared.
Now *that* is the speculation for which Tim will chop off your head. :-) --Guido van Rossum (home page: http://www.python.org/~guido/)

"Martin v. Loewis" wrote:
Good to know, thanks.
Sounds like you have experience ;-) As with all micro-optimizations, the win usually only shows up in some applications. The one I'm writing uses lot's of if tagtype == 'starttag': if tagtype == 'endtag': ... Since the 'starttag' and 'endtag' strings are interned and I'm also interning the strings which are stored in tagtype, I'd like to benefit from the fact that the compare will actually work as 'is'-compare. However, I don't want to use 'is' because I consider interning only an optimization and not a feature of the language. That's why I would like the simple if (v == w) return 0; integrated into the ceval loop right along the INT-compare optimization. This may also help in some other situations where objects are shared. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/

Agreed.
Maybe this could be done as follows: if (v == w && PyString_CheckExact(v)) return 0;
This may also help in some other situations where objects are shared.
Now *that* is the speculation for which Tim will chop off your head. :-) --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (3)
-
Guido van Rossum
-
M.-A. Lemburg
-
Martin v. Loewis