Tim Delaney wrote: > From: "Calvin Spealman" <[EMAIL PROTECTED]> > >> I believe the direction my PEP took with all this is a good bit >> primitive compared to this approach, although I still find value in it >> because at least a prototype came out of it that can be used to test >> the waters, regardless of if a more direct-in-the-language approach >> would be superior. > > I've been working on improved super syntax for quite a while now - my > original approach was 'self.super' which used _getframe() and mro crawling > too. I hit on using bytecode hacking to instantiate a super object at the > start of the method to gain performance, which required storing the class in > co_consts, etc. It turns out that using a metaclass then makes this a lot > cleaner. > >> However, I seem to think that if the __this_class__ PEP goes through, >> your version can be simplified as well. No tricky stuffy things in >> cells would be needed, but we can just expand the super 'keyword' to >> __super__(__this_class__, self), which has been suggested at least >> once. It seems this would be much simpler to implement, and it also >> brings up a second point. >> >> Also, I like that the super object is created at the beginning of the >> function, which my proposal couldn't even do. It is more efficient if >> you have multiple super calls, and gets around a problem I completely >> missed: what happens if the instance name were rebound before the >> implicit lookup of the instance object at the time of the super call? > > You could expand it inline, but I think your second point is a strong > argument against it. Also, sticking the super instance into a cell means > that inner classes get access to it for free. Otherwise each inner class > would *also* need to instantiate a super instance, and __this_class__ (or > whatever it's called) would need to be in a cell for them to get access to > it instead. > > BTW, one of my test cases involves multiple super calls in the same method - > there is a *very* large performance improvement by instantiating it once. > And how does speed deteriorate for methods with no uses of super at all (which will, I suspect, be in the majority)?
regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden ------------------ Asciimercial --------------------- Get on the web: Blog, lens and tag your way to fame!! holdenweb.blogspot.com squidoo.com/pythonology tagged items: del.icio.us/steve.holden/python All these services currently offer free registration! -------------- Thank You for Reading ---------------- _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com