Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 42193:090588a17490
Merged revisions 56154-56264 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56155 | neal.norwitz | 2007-07-03 08:59:08 +0300 (Tue, 03 Jul 2007) | 1 line
Get this test working after converting map to return an iterator
................
r56202 | neal.norwitz | 2007-07-09 04:30:09 +0300 (Mon, 09 Jul 2007) | 37 lines
Merged revisions 56124-56201 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56129 | georg.brandl | 2007-06-30 04:01:01 -0700 (Sat, 30 Jun 2007) | 2 lines
Document smtp.SMTPAuthenticationError.
........
r56137 | georg.brandl | 2007-07-01 01:11:35 -0700 (Sun, 01 Jul 2007) | 2 lines
Fix a few webbrowser.py problems.
........
r56143 | georg.brandl | 2007-07-02 04:54:28 -0700 (Mon, 02 Jul 2007) | 2 lines
Remove duplicate sentence from alarm() doc.
........
r56170 | mark.hammond | 2007-07-03 19:03:10 -0700 (Tue, 03 Jul 2007) | 3 lines
copy built files to the PCBuild directory, where tools like
distutils or external build processes can find them.
........
r56176 | kurt.kaiser | 2007-07-05 15:03:39 -0700 (Thu, 05 Jul 2007) | 10 lines
Many calls to tk.call involve an arglist containing a single tuple.
Calls using METH_OLDARGS unpack this tuple; calls using METH_VARARG
don't. Tcl's concatenation of args was affected; IDLE doesn't start.
Modify Tkapp_Call() to unpack single tuple arglists.
Bug 1733943
Ref http://mail.python.org/pipermail/python-checkins/2007-May/060454.html
........
r56177 | neal.norwitz | 2007-07-05 21:13:39 -0700 (Thu, 05 Jul 2007) | 1 line
Fix typo in comment
........
................
r56251 | neal.norwitz | 2007-07-11 10:01:01 +0300 (Wed, 11 Jul 2007) | 1 line
Get working with map returning an iterator (had to fix whitespace too)
................
r56255 | thomas.wouters | 2007-07-11 13:41:37 +0300 (Wed, 11 Jul 2007) | 6 lines
Clean up merge glitch or copy-paste error (the entire module was duplicated,
except the first half even had some more copy-paste errors, referring to
listcomps and genexps instead of setcomps)
................
r56256 | thomas.wouters | 2007-07-11 15:16:01 +0300 (Wed, 11 Jul 2007) | 14 lines
Dict comprehensions. Still needs doc changes (like many python-3000 features
;-). It generates bytecode similar to:
x = {}
for k, v in (generator here):
x[k] = v
except there is no tuple-packing and -unpacking involved. Trivial
measurement suggests it's significantly faster than dict(generator here) (in
the order of 2 to 3 times as fast) but I have not done extensive
measurements.
................
r56263 | guido.van.rossum | 2007-07-11 15:36:26 +0300 (Wed, 11 Jul 2007) | 3 lines
Patch 1724999 by Ali Gholami Rudi -- avoid complaints about dict size
change during iter in destroy call.
................
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 11 Jul 2007 13:09:30 +0000 |
| parents | cd125fe83051 |
| children | d1c7c2543903 |
comparison
equal
deleted
inserted
replaced
| 42192:1ac2c1b80324 | 42193:090588a17490 |
|---|---|
| 194 "generators", | 194 "generators", |
| 195 }; | 195 }; |
| 196 static PyTypeObject *SetComp_type; | 196 static PyTypeObject *SetComp_type; |
| 197 static char *SetComp_fields[]={ | 197 static char *SetComp_fields[]={ |
| 198 "elt", | 198 "elt", |
| 199 "generators", | |
| 200 }; | |
| 201 static PyTypeObject *DictComp_type; | |
| 202 static char *DictComp_fields[]={ | |
| 203 "key", | |
| 204 "value", | |
| 199 "generators", | 205 "generators", |
| 200 }; | 206 }; |
| 201 static PyTypeObject *GeneratorExp_type; | 207 static PyTypeObject *GeneratorExp_type; |
| 202 static char *GeneratorExp_fields[]={ | 208 static char *GeneratorExp_fields[]={ |
| 203 "elt", | 209 "elt", |
| 549 if (!Set_type) return 0; | 555 if (!Set_type) return 0; |
| 550 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2); | 556 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2); |
| 551 if (!ListComp_type) return 0; | 557 if (!ListComp_type) return 0; |
| 552 SetComp_type = make_type("SetComp", expr_type, SetComp_fields, 2); | 558 SetComp_type = make_type("SetComp", expr_type, SetComp_fields, 2); |
| 553 if (!SetComp_type) return 0; | 559 if (!SetComp_type) return 0; |
| 560 DictComp_type = make_type("DictComp", expr_type, DictComp_fields, 3); | |
| 561 if (!DictComp_type) return 0; | |
| 554 GeneratorExp_type = make_type("GeneratorExp", expr_type, | 562 GeneratorExp_type = make_type("GeneratorExp", expr_type, |
| 555 GeneratorExp_fields, 2); | 563 GeneratorExp_fields, 2); |
| 556 if (!GeneratorExp_type) return 0; | 564 if (!GeneratorExp_type) return 0; |
| 557 Yield_type = make_type("Yield", expr_type, Yield_fields, 1); | 565 Yield_type = make_type("Yield", expr_type, Yield_fields, 1); |
| 558 if (!Yield_type) return 0; | 566 if (!Yield_type) return 0; |
| 1443 p->col_offset = col_offset; | 1451 p->col_offset = col_offset; |
| 1444 return p; | 1452 return p; |
| 1445 } | 1453 } |
| 1446 | 1454 |
| 1447 expr_ty | 1455 expr_ty |
| 1456 DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int | |
| 1457 col_offset, PyArena *arena) | |
| 1458 { | |
| 1459 expr_ty p; | |
| 1460 if (!key) { | |
| 1461 PyErr_SetString(PyExc_ValueError, | |
| 1462 "field key is required for DictComp"); | |
| 1463 return NULL; | |
| 1464 } | |
| 1465 if (!value) { | |
| 1466 PyErr_SetString(PyExc_ValueError, | |
| 1467 "field value is required for DictComp"); | |
| 1468 return NULL; | |
| 1469 } | |
| 1470 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | |
| 1471 if (!p) | |
| 1472 return NULL; | |
| 1473 p->kind = DictComp_kind; | |
| 1474 p->v.DictComp.key = key; | |
| 1475 p->v.DictComp.value = value; | |
| 1476 p->v.DictComp.generators = generators; | |
| 1477 p->lineno = lineno; | |
| 1478 p->col_offset = col_offset; | |
| 1479 return p; | |
| 1480 } | |
| 1481 | |
| 1482 expr_ty | |
| 1448 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, | 1483 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, |
| 1449 PyArena *arena) | 1484 PyArena *arena) |
| 1450 { | 1485 { |
| 1451 expr_ty p; | 1486 expr_ty p; |
| 1452 if (!elt) { | 1487 if (!elt) { |
| 2471 if (!value) goto failed; | 2506 if (!value) goto failed; |
| 2472 if (PyObject_SetAttrString(result, "elt", value) == -1) | 2507 if (PyObject_SetAttrString(result, "elt", value) == -1) |
| 2473 goto failed; | 2508 goto failed; |
| 2474 Py_DECREF(value); | 2509 Py_DECREF(value); |
| 2475 value = ast2obj_list(o->v.SetComp.generators, | 2510 value = ast2obj_list(o->v.SetComp.generators, |
| 2511 ast2obj_comprehension); | |
| 2512 if (!value) goto failed; | |
| 2513 if (PyObject_SetAttrString(result, "generators", value) == -1) | |
| 2514 goto failed; | |
| 2515 Py_DECREF(value); | |
| 2516 break; | |
| 2517 case DictComp_kind: | |
| 2518 result = PyType_GenericNew(DictComp_type, NULL, NULL); | |
| 2519 if (!result) goto failed; | |
| 2520 value = ast2obj_expr(o->v.DictComp.key); | |
| 2521 if (!value) goto failed; | |
| 2522 if (PyObject_SetAttrString(result, "key", value) == -1) | |
| 2523 goto failed; | |
| 2524 Py_DECREF(value); | |
| 2525 value = ast2obj_expr(o->v.DictComp.value); | |
| 2526 if (!value) goto failed; | |
| 2527 if (PyObject_SetAttrString(result, "value", value) == -1) | |
| 2528 goto failed; | |
| 2529 Py_DECREF(value); | |
| 2530 value = ast2obj_list(o->v.DictComp.generators, | |
| 2476 ast2obj_comprehension); | 2531 ast2obj_comprehension); |
| 2477 if (!value) goto failed; | 2532 if (!value) goto failed; |
| 2478 if (PyObject_SetAttrString(result, "generators", value) == -1) | 2533 if (PyObject_SetAttrString(result, "generators", value) == -1) |
| 2479 goto failed; | 2534 goto failed; |
| 2480 Py_DECREF(value); | 2535 Py_DECREF(value); |
| 3183 if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return; | 3238 if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return; |
| 3184 if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return; | 3239 if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return; |
| 3185 if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0) | 3240 if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0) |
| 3186 return; | 3241 return; |
| 3187 if (PyDict_SetItemString(d, "SetComp", (PyObject*)SetComp_type) < 0) | 3242 if (PyDict_SetItemString(d, "SetComp", (PyObject*)SetComp_type) < 0) |
| 3243 return; | |
| 3244 if (PyDict_SetItemString(d, "DictComp", (PyObject*)DictComp_type) < 0) | |
| 3188 return; | 3245 return; |
| 3189 if (PyDict_SetItemString(d, "GeneratorExp", | 3246 if (PyDict_SetItemString(d, "GeneratorExp", |
| 3190 (PyObject*)GeneratorExp_type) < 0) return; | 3247 (PyObject*)GeneratorExp_type) < 0) return; |
| 3191 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return; | 3248 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return; |
| 3192 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) | 3249 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) |
