Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions fixtures/bench_accumulator_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def accumulator(sum):
def f(n):
nonlocal sum
sum += n
return sum
return f

x = accumulator(1)
x(5)
print(accumulator(3))
print(x(2.3))
309 changes: 309 additions & 0 deletions fixtures/bench_accumulator_factory.py.native
Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@
{
'PY3AST': {
'ast_type': "Module",
body: [
{
args: {
args: [
{
'@token': "sum",
annotation: ~,
'ast_type': "arg",
'col_offset': 17,
'end_col_offset': 20,
'end_lineno': 1,
lineno: 1,
},
],
'ast_type': "arguments",
},
'ast_type': "FunctionDef",
body: [
{
args: {
args: [
{
'@token': "n",
annotation: ~,
'ast_type': "arg",
'col_offset': 9,
'end_col_offset': 10,
'end_lineno': 2,
lineno: 2,
},
],
'ast_type': "arguments",
},
'ast_type': "FunctionDef",
body: [
{
'ast_type': "Nonlocal",
'col_offset': 5,
'end_col_offset': 13,
'end_lineno': 3,
lineno: 3,
names: [
{
'ast_type': "Name",
'col_offset': 14,
'end_col_offset': 17,
'end_lineno': 3,
id: "sum",
lineno: 3,
},
],
},
{
'ast_type': "AugAssign",
'col_offset': 9,
'end_col_offset': 11,
'end_lineno': 4,
lineno: 4,
op: {
'ast_type': "Add",
},
target: {
'ast_type': "Name",
'col_offset': 5,
ctx: "Store",
'end_col_offset': 8,
'end_lineno': 4,
id: "sum",
lineno: 4,
},
value: {
'ast_type': "Name",
'col_offset': 12,
ctx: "Load",
'end_col_offset': 13,
'end_lineno': 4,
id: "n",
lineno: 4,
},
},
{
'ast_type': "Return",
'col_offset': 5,
'end_col_offset': 11,
'end_lineno': 5,
lineno: 5,
value: {
'ast_type': "Name",
'col_offset': 12,
ctx: "Load",
'end_col_offset': 15,
'end_lineno': 5,
id: "sum",
lineno: 5,
},
},
],
'col_offset': 7,
'decorator_list': [],
'end_col_offset': 8,
'end_lineno': 2,
lineno: 2,
name: "f",
returns: ~,
},
{
'ast_type': "Return",
'col_offset': 3,
'end_col_offset': 9,
'end_lineno': 6,
lineno: 6,
value: {
'ast_type': "Name",
'col_offset': 10,
ctx: "Load",
'end_col_offset': 11,
'end_lineno': 6,
id: "f",
lineno: 6,
},
},
],
'col_offset': 5,
'decorator_list': [],
'end_col_offset': 16,
'end_lineno': 1,
lineno: 1,
name: "accumulator",
returns: ~,
},
{
'ast_type': "Assign",
'col_offset': 1,
lineno: 8,
targets: [
{
'ast_type': "Name",
'col_offset': 1,
ctx: "Store",
'end_col_offset': 2,
'end_lineno': 8,
id: "x",
lineno: 8,
'noops_previous': {
'ast_type': "PreviousNoops",
'col_offset': 1,
'end_col_offset': 1,
'end_lineno': 7,
lineno: 7,
lines: [],
},
},
],
value: {
args: [
{
'ast_type': "Num",
'col_offset': 17,
'end_col_offset': 18,
'end_lineno': 8,
lineno: 8,
'n': 1,
},
],
'ast_type': "Call",
'col_offset': 5,
func: {
'ast_type': "Name",
'col_offset': 5,
ctx: "Load",
'end_col_offset': 16,
'end_lineno': 8,
id: "accumulator",
lineno: 8,
},
keywords: [],
lineno: 8,
},
},
{
'ast_type': "Expr",
'col_offset': 1,
lineno: 9,
value: {
args: [
{
'ast_type': "Num",
'col_offset': 3,
'end_col_offset': 4,
'end_lineno': 9,
lineno: 9,
'n': 5,
},
],
'ast_type': "Call",
'col_offset': 1,
func: {
'ast_type': "Name",
'col_offset': 1,
ctx: "Load",
'end_col_offset': 2,
'end_lineno': 9,
id: "x",
lineno: 9,
},
keywords: [],
lineno: 9,
},
},
{
'ast_type': "Expr",
'col_offset': 1,
lineno: 10,
value: {
args: [
{
args: [
{
'ast_type': "Num",
'col_offset': 19,
'end_col_offset': 20,
'end_lineno': 10,
lineno: 10,
'n': 3,
},
],
'ast_type': "Call",
'col_offset': 7,
func: {
'ast_type': "Name",
'col_offset': 7,
ctx: "Load",
'end_col_offset': 18,
'end_lineno': 10,
id: "accumulator",
lineno: 10,
},
keywords: [],
lineno: 10,
},
],
'ast_type': "Call",
'col_offset': 1,
func: {
'ast_type': "Name",
'col_offset': 1,
ctx: "Load",
'end_col_offset': 6,
'end_lineno': 10,
id: "print",
lineno: 10,
},
keywords: [],
lineno: 10,
},
},
{
'ast_type': "Expr",
'col_offset': 1,
lineno: 11,
value: {
args: [
{
args: [
{
'ast_type': "Num",
'col_offset': 9,
'end_col_offset': 12,
'end_lineno': 11,
lineno: 11,
'n': 2.3,
},
],
'ast_type': "Call",
'col_offset': 7,
func: {
'ast_type': "Name",
'col_offset': 7,
ctx: "Load",
'end_col_offset': 8,
'end_lineno': 11,
id: "x",
lineno: 11,
},
keywords: [],
lineno: 11,
},
],
'ast_type': "Call",
'col_offset': 1,
func: {
'ast_type': "Name",
'col_offset': 1,
ctx: "Load",
'end_col_offset': 6,
'end_lineno': 11,
id: "print",
lineno: 11,
},
keywords: [],
lineno: 11,
},
},
],
},
}
Loading