--- a/Python/compile.c +++ b/Python/compile.c @@ -3219,21 +3219,32 @@ compiler_assert(struct compiler *c, stmt_ty s) if (assertion_error == NULL) return 0; } + /* Hai Shi: Why don't we move those code to the top of this function? + * If we move those code to the top, looks we could get little improvement + * due to not calling PyUnicode_InternFromString. + */ if (s->v.Assert.test->kind == Tuple_kind && asdl_seq_LEN(s->v.Assert.test->v.Tuple.elts) > 0) { if (!compiler_warn(c, "assertion is always true, " "perhaps remove parentheses?")) { + Py_DECREF(assertion_error); return 0; } } end = compiler_new_block(c); if (end == NULL) + { + Py_DECREF(assertion_error); return 0; + } if (!compiler_jump_if(c, s->v.Assert.test, end, 1)) + { + Py_DECREF(assertion_error); return 0; - ADDOP_O(c, LOAD_GLOBAL, assertion_error, names); + } + ADDOP_N(c, LOAD_GLOBAL, assertion_error, names); if (s->v.Assert.msg) { VISIT(c, expr, s->v.Assert.msg); ADDOP_I(c, CALL_FUNCTION, 1);