Skip to content

Commit ca6e332

Browse files
committed
Move some comments
1 parent 5e269fb commit ca6e332

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

Python/ceval.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,11 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where)
884884
// PEP 634: Structural Pattern Matching
885885

886886

887+
// Return a tuple of values corresponding to keys, with error checks for
888+
// duplicate/missing keys.
887889
static PyObject*
888890
match_keys(PyThreadState *tstate, PyObject *map, PyObject *keys)
889891
{
890-
// Return a tuple of values corresponding to keys, with error checks for
891-
// duplicate/missing keys.
892892
assert(PyTuple_CheckExact(keys));
893893
Py_ssize_t nkeys = PyTuple_GET_SIZE(keys);
894894
if (!nkeys) {
@@ -961,13 +961,13 @@ match_keys(PyThreadState *tstate, PyObject *map, PyObject *keys)
961961
return NULL;
962962
}
963963

964+
// Extract a named attribute from the subject, with additional bookkeeping to
965+
// raise TypeErrors for repeated lookups. On failure, return NULL (with no
966+
// error set). Use _PyErr_Occurred(tstate) to disambiguate.
964967
static PyObject*
965968
match_class_attr(PyThreadState *tstate, PyObject *subject, PyObject *type,
966969
PyObject *name, PyObject *seen)
967970
{
968-
// Extract a named attribute from the subject, with additional bookkeeping
969-
// to raise TypeErrors for repeated lookups. On failure, return NULL (with
970-
// no error set). Use _PyErr_Occurred(tstate) to disambiguate.
971971
assert(PyUnicode_CheckExact(name));
972972
assert(PySet_CheckExact(seen));
973973
if (PySet_Contains(seen, name) || PySet_Add(seen, name)) {
@@ -986,12 +986,12 @@ match_class_attr(PyThreadState *tstate, PyObject *subject, PyObject *type,
986986
return attr;
987987
}
988988

989+
// On success (match), return a tuple of extracted attributes. On failure (no
990+
// match), return NULL. Use _PyErr_Occurred(tstate) to disambiguate.
989991
static PyObject*
990992
match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
991993
Py_ssize_t nargs, PyObject *kwargs)
992994
{
993-
// On success (match), return a tuple of extracted attributes. On failure
994-
// (no match), return NULL. Use _PyErr_Occurred(tstate) to disambiguate.
995995
if (!PyType_Check(type)) {
996996
const char *e = "called match pattern must be a type";
997997
_PyErr_Format(tstate, PyExc_TypeError, e);

Python/compile.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5568,14 +5568,13 @@ pattern_helper_sequence_unpack(struct compiler *c, asdl_expr_seq *values,
55685568
return 0;
55695569
}
55705570

5571-
5571+
// Like pattern_helper_sequence_unpack, but uses BINARY_SUBSCR instead of
5572+
// UNPACK_SEQUENCE / UNPACK_EX. This is more efficient for patterns with a
5573+
// starred wildcard like [first, *_] / [first, *_, last] / [*_, last] / etc.
55725574
static int
55735575
pattern_helper_sequence_subscr(struct compiler *c, asdl_expr_seq *values,
55745576
Py_ssize_t star, pattern_context *pc)
55755577
{
5576-
// Like pattern_helper_sequence_unpack, but uses BINARY_SUBSCR instead of
5577-
// UNPACK_SEQUENCE / UNPACK_EX. This is more efficient for patterns with a
5578-
// starred wildcard like [first, *_] / [first, *_, last] / [*_, last] / etc.
55795578
basicblock *end, *fail_pop_1;
55805579
RETURN_IF_FALSE(end = compiler_new_block(c));
55815580
RETURN_IF_FALSE(fail_pop_1 = compiler_new_block(c));
@@ -5617,10 +5616,10 @@ pattern_helper_sequence_subscr(struct compiler *c, asdl_expr_seq *values,
56175616
}
56185617

56195618

5619+
// Like compiler_pattern, but turn off checks for irrefutability.
56205620
static int
56215621
compiler_pattern_subpattern(struct compiler *c, expr_ty p, pattern_context *pc)
56225622
{
5623-
// Like compiler_pattern, but turn off checks for irrefutability.
56245623
int allow_irrefutable = pc->allow_irrefutable;
56255624
pc->allow_irrefutable = 1;
56265625
RETURN_IF_FALSE(compiler_pattern(c, p, pc));

0 commit comments

Comments
 (0)