[issue12473] factory func of collections.defaultdict should receive the "missing key" as args when called.

2011-07-02 Thread HaiYun Yan

New submission from HaiYun Yan :

for example:

def calc(params):
""" i am factoring numbers. """
# an expensive CPU cost function but 
# passin params and return result are both lightweight

cachedcalc = collections.defaultdict(calc)
result = cachedcalc[0xFFF0AC0FFF1]

--
components: Library (Lib)
messages: 139624
nosy: lyricconch
priority: normal
severity: normal
status: open
title: factory func of collections.defaultdict should receive the "missing key" 
as args when called.
type: behavior
versions: Python 2.7

___
Python tracker 
<http://bugs.python.org/issue12473>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12635] use "as" for block scope support

2011-07-25 Thread HaiYun Yan

New submission from HaiYun Yan :

use "as" for block scope support
just like mozilla javascript "let" extension
https://developer.mozilla.org/en/new_in_javascript_1.7#Block_scope_with_let_%28Merge_into_let_Statement%29

usage:

as_clause(as_declare): "as" NAME
as_stmt: NAME "as" test
as_expr: "(" expr "as" NAME ")" expr

var declare by as_clause is alive in  only
eg:
with open(...) as f:
   ...


the same rule to "except E as e: "

spec:
from socket import AF_INET as IPv4

IPv4 = None
assert socket.AF_INET == None

var in as_stmt is alive in current indentation
eg:
for i in range(10):
   
   t as f()+1 
   ...
   

var in as_expr is alive in sub expr only
eg:
t = None
x = (2+3 as t) t**2
assert t == None ane  x == 25

Suggestion:
new opcode
ENTER_BLOCK #depth #varslots

--
components: Interpreter Core
messages: 141076
nosy: lyricconch
priority: normal
severity: normal
status: open
title: use "as" for block scope support
type: feature request

___
Python tracker 
<http://bugs.python.org/issue12635>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com