Re: [Python-Dev] Can LOAD_GLOBAL be optimized to a simple array lookup?

2006-08-24 Thread K.S.Sreeram
Tim Peters wrote: > Note that there are already three PEPs related to speeding dict-based > namespace access; start with: > > http://www.python.org/dev/peps/pep-0280/ > > which references the other two. > > The "normal path" through dict lookups got faster since there was a > rash of those,

Re: [Python-Dev] Can LOAD_GLOBAL be optimized to a simple array lookup?

2006-08-24 Thread K.S.Sreeram
Alex Martelli wrote: > > On Aug 23, 2006, at 2:22 PM, K.S.Sreeram wrote: > >> Hi all, >> >> I noticed in Python/ceval.c that LOAD_GLOBAL uses a dictionary lookup, >> and was wondering if that can be optimized to a simple array lookup. >> >> If i'

[Python-Dev] Can LOAD_GLOBAL be optimized to a simple array lookup?

2006-08-23 Thread K.S.Sreeram
Hi all, I noticed in Python/ceval.c that LOAD_GLOBAL uses a dictionary lookup, and was wondering if that can be optimized to a simple array lookup. If i'm right there are 3 kinds of name lookups: locals, outer scopes(closures), and globals. (not counting attribute lookup). Locals are identified b

Re: [Python-Dev] Proposal: Add Sudoku Solver To The "this" Module

2006-07-13 Thread K.S.Sreeram
Fredrik Lundh wrote: > given that java has beaten us with some 60 bytes: > and in order to further improve Python's Kolmogorov rating: > how about adding Peter Norvig's constraint-based solver to the Python library: lol! (just waiting for somebody to give a serious explanation on why this is a bad

Re: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)

2006-07-11 Thread K.S.Sreeram
Talin wrote: > def x(): >scope = object() >scope.x = 1 >def y(): > scope.x = 2 'object' doesn't let you set custom attributes. Here's what I normally use in my code... class Data : pass def x() : d = Data() d.x = 1 def y() : d.x += 1 Re

Re: [Python-Dev] PEP 3103: A Switch/Case Statement

2006-06-27 Thread K.S.Sreeram
Guido van Rossum wrote: > I think we need a PEP for const/static/only/cached/precomputed or > whatever people like to call it. fredrik's got a micro pep at http://online.effbot.org > Once we have (say) static, I think making the case expressions static > by default would still cover all useful ca