rapydscript-ns 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/.agignore +1 -1
  2. package/.github/workflows/ci.yml +38 -38
  3. package/=template.pyj +5 -5
  4. package/CHANGELOG.md +39 -0
  5. package/HACKING.md +103 -103
  6. package/LICENSE +24 -24
  7. package/PYTHON_DIFFERENCES_REPORT.md +291 -0
  8. package/PYTHON_FEATURE_COVERAGE.md +106 -15
  9. package/README.md +831 -52
  10. package/TODO.md +4 -286
  11. package/add-toc-to-readme +2 -2
  12. package/bin/export +75 -75
  13. package/bin/rapydscript +70 -70
  14. package/bin/web-repl-export +102 -102
  15. package/build +2 -2
  16. package/language-service/index.js +4623 -0
  17. package/language-service/language-service.d.ts +40 -0
  18. package/package.json +9 -7
  19. package/publish.py +37 -37
  20. package/release/baselib-plain-pretty.js +2006 -229
  21. package/release/baselib-plain-ugly.js +70 -3
  22. package/release/compiler.js +11554 -3870
  23. package/release/signatures.json +31 -29
  24. package/session.vim +4 -4
  25. package/setup.cfg +2 -2
  26. package/src/ast.pyj +93 -1
  27. package/src/baselib-builtins.pyj +99 -2
  28. package/src/baselib-containers.pyj +107 -4
  29. package/src/baselib-errors.pyj +44 -0
  30. package/src/baselib-internal.pyj +124 -5
  31. package/src/baselib-itertools.pyj +97 -97
  32. package/src/baselib-str.pyj +32 -1
  33. package/src/compiler.pyj +36 -36
  34. package/src/errors.pyj +30 -30
  35. package/src/lib/aes.pyj +646 -646
  36. package/src/lib/collections.pyj +1 -1
  37. package/src/lib/copy.pyj +120 -0
  38. package/src/lib/elementmaker.pyj +83 -83
  39. package/src/lib/encodings.pyj +126 -126
  40. package/src/lib/gettext.pyj +569 -569
  41. package/src/lib/itertools.pyj +580 -580
  42. package/src/lib/math.pyj +193 -193
  43. package/src/lib/numpy.pyj +10 -10
  44. package/src/lib/operator.pyj +11 -11
  45. package/src/lib/pythonize.pyj +20 -20
  46. package/src/lib/random.pyj +118 -118
  47. package/src/lib/re.pyj +470 -470
  48. package/src/lib/react.pyj +74 -0
  49. package/src/lib/traceback.pyj +63 -63
  50. package/src/lib/uuid.pyj +77 -77
  51. package/src/monaco-language-service/analyzer.js +131 -9
  52. package/src/monaco-language-service/builtins.js +17 -2
  53. package/src/monaco-language-service/completions.js +170 -1
  54. package/src/monaco-language-service/diagnostics.js +25 -3
  55. package/src/monaco-language-service/dts.js +550 -550
  56. package/src/monaco-language-service/index.js +17 -0
  57. package/src/monaco-language-service/scope.js +3 -0
  58. package/src/output/classes.pyj +128 -11
  59. package/src/output/codegen.pyj +17 -3
  60. package/src/output/comments.pyj +45 -45
  61. package/src/output/exceptions.pyj +201 -105
  62. package/src/output/functions.pyj +13 -16
  63. package/src/output/jsx.pyj +164 -0
  64. package/src/output/literals.pyj +28 -2
  65. package/src/output/loops.pyj +0 -9
  66. package/src/output/modules.pyj +2 -5
  67. package/src/output/operators.pyj +22 -2
  68. package/src/output/statements.pyj +2 -2
  69. package/src/output/stream.pyj +1 -13
  70. package/src/output/treeshake.pyj +182 -182
  71. package/src/output/utils.pyj +72 -72
  72. package/src/parse.pyj +434 -114
  73. package/src/string_interpolation.pyj +72 -72
  74. package/src/tokenizer.pyj +29 -0
  75. package/src/unicode_aliases.pyj +576 -576
  76. package/src/utils.pyj +192 -192
  77. package/test/_import_one.pyj +37 -37
  78. package/test/_import_two/__init__.pyj +11 -11
  79. package/test/_import_two/level2/deep.pyj +4 -4
  80. package/test/_import_two/other.pyj +6 -6
  81. package/test/_import_two/sub.pyj +13 -13
  82. package/test/aes_vectors.pyj +421 -421
  83. package/test/annotations.pyj +80 -80
  84. package/test/baselib.pyj +4 -4
  85. package/test/classes.pyj +56 -17
  86. package/test/collections.pyj +5 -5
  87. package/test/decorators.pyj +77 -77
  88. package/test/docstrings.pyj +39 -39
  89. package/test/elementmaker_test.pyj +45 -45
  90. package/test/functions.pyj +151 -151
  91. package/test/generators.pyj +41 -41
  92. package/test/generic.pyj +370 -370
  93. package/test/imports.pyj +72 -72
  94. package/test/internationalization.pyj +73 -73
  95. package/test/lint.pyj +164 -164
  96. package/test/loops.pyj +85 -85
  97. package/test/numpy.pyj +734 -734
  98. package/test/omit_function_metadata.pyj +20 -20
  99. package/test/python_compat.pyj +326 -0
  100. package/test/python_features.pyj +129 -29
  101. package/test/regexp.pyj +55 -55
  102. package/test/repl.pyj +121 -121
  103. package/test/scoped_flags.pyj +76 -76
  104. package/test/slice.pyj +105 -0
  105. package/test/str.pyj +25 -0
  106. package/test/unit/fixtures/fibonacci_expected.js +1 -1
  107. package/test/unit/index.js +2296 -71
  108. package/test/unit/language-service-builtins.js +70 -0
  109. package/test/unit/language-service-bundle.js +5 -5
  110. package/test/unit/language-service-completions.js +180 -0
  111. package/test/unit/language-service-dts.js +543 -543
  112. package/test/unit/language-service-hover.js +455 -455
  113. package/test/unit/language-service-index.js +350 -0
  114. package/test/unit/language-service-scope.js +255 -0
  115. package/test/unit/language-service.js +625 -4
  116. package/test/unit/run-language-service.js +1 -0
  117. package/test/unit/web-repl.js +437 -0
  118. package/tools/build-language-service.js +2 -2
  119. package/tools/cli.js +547 -547
  120. package/tools/compile.js +219 -219
  121. package/tools/compiler.js +0 -24
  122. package/tools/completer.js +131 -131
  123. package/tools/embedded_compiler.js +251 -251
  124. package/tools/export.js +3 -37
  125. package/tools/gettext.js +185 -185
  126. package/tools/ini.js +65 -65
  127. package/tools/msgfmt.js +187 -187
  128. package/tools/repl.js +223 -223
  129. package/tools/test.js +118 -118
  130. package/tools/utils.js +128 -128
  131. package/tools/web_repl.js +95 -95
  132. package/try +41 -41
  133. package/web-repl/env.js +196 -74
  134. package/web-repl/index.html +163 -163
  135. package/web-repl/main.js +252 -254
  136. package/web-repl/prism.css +139 -139
  137. package/web-repl/prism.js +113 -113
  138. package/web-repl/rapydscript.js +227 -139
  139. package/web-repl/sha1.js +25 -25
  140. package/hack_demo.pyj +0 -112
  141. package/web-repl/language-service.js +0 -4187
@@ -1,23 +1,48 @@
1
- var ρσ_len;
1
+ let ρσ_len;
2
2
  function ρσ_bool(val) {
3
- return !!val;
3
+ if (val === null || val === undefined) return false;
4
+ var ρσ_bool_t = typeof val;
5
+ if (ρσ_bool_t === "boolean") return val;
6
+ if (ρσ_bool_t === "number") return val !== 0;
7
+ if (ρσ_bool_t === "string") return val.length > 0;
8
+ if (ρσ_bool_t === "function") return true;
9
+ if (val.constructor && val.constructor.prototype === val) return true;
10
+ if (typeof val.__bool__ === "function") return !!val.__bool__();
11
+ if (Array.isArray(val)) return val.length > 0;
12
+ if (typeof val.__len__ === "function") return val.__len__() > 0;
13
+ if ((typeof Set === "function" && val instanceof Set) || (typeof Map === "function" && val instanceof Map)) return val.size > 0;
14
+ if (!val.constructor || val.constructor === Object) return Object.keys(val).length > 0;
15
+ return true;
4
16
  };
5
17
  if (!ρσ_bool.__argnames__) Object.defineProperties(ρσ_bool, {
6
18
  __argnames__ : {value: ["val"]},
7
19
  __module__ : {value: "__main__"}
8
20
  });
9
21
 
22
+ ρσ_bool.__name__ = "bool";
10
23
  function ρσ_print() {
11
- var parts;
24
+ var kwargs = arguments[arguments.length-1];
25
+ if (kwargs === null || typeof kwargs !== "object" || kwargs [ρσ_kwargs_symbol] !== true) kwargs = {};
26
+ var args = Array.prototype.slice.call(arguments, 0);
27
+ if (kwargs !== null && typeof kwargs === "object" && kwargs [ρσ_kwargs_symbol] === true) args.pop();
28
+ kwargs = ρσ_kwargs_to_dict(kwargs);
29
+ var sep, parts, a;
12
30
  if (typeof console === "object") {
13
- parts = [];
14
- for (var i = 0; i < arguments.length; i++) {
15
- parts.push(ρσ_str(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]));
16
- }
17
- console.log(parts.join(" "));
31
+ sep = (kwargs.sep !== undefined) ? kwargs.sep : " ";
32
+ parts = (function() {
33
+ var ρσ_Iter = ρσ_Iterable(args), ρσ_Result = [], a;
34
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
35
+ a = ρσ_Iter[ρσ_Index];
36
+ ρσ_Result.push(ρσ_str(a));
37
+ }
38
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
39
+ return ρσ_Result;
40
+ })();
41
+ console.log(parts.join(sep));
18
42
  }
19
43
  };
20
- if (!ρσ_print.__module__) Object.defineProperties(ρσ_print, {
44
+ if (!ρσ_print.__handles_kwarg_interpolation__) Object.defineProperties(ρσ_print, {
45
+ __handles_kwarg_interpolation__ : {value: true},
21
46
  __module__ : {value: "__main__"}
22
47
  });
23
48
 
@@ -29,7 +54,7 @@ function ρσ_int(val, base) {
29
54
  ans = parseInt(val, base || 10);
30
55
  }
31
56
  if (isNaN(ans)) {
32
- throw new ValueError("Invalid literal for int with base " + (base || 10) + ": " + val);
57
+ throw new ValueError(ρσ_list_add(ρσ_list_add(ρσ_list_add("Invalid literal for int with base ", (base || 10)), ": "), val));
33
58
  }
34
59
  return ans;
35
60
  };
@@ -38,6 +63,7 @@ if (!ρσ_int.__argnames__) Object.defineProperties(ρσ_int, {
38
63
  __module__ : {value: "__main__"}
39
64
  });
40
65
 
66
+ ρσ_int.__name__ = "int";
41
67
  function ρσ_float(val) {
42
68
  var ans;
43
69
  if (typeof val === "number") {
@@ -46,7 +72,7 @@ function ρσ_float(val) {
46
72
  ans = parseFloat(val);
47
73
  }
48
74
  if (isNaN(ans)) {
49
- throw new ValueError("Could not convert string to float: " + arguments[0]);
75
+ throw new ValueError(ρσ_list_add("Could not convert string to float: ", arguments[0]));
50
76
  }
51
77
  return ans;
52
78
  };
@@ -55,6 +81,7 @@ if (!ρσ_float.__argnames__) Object.defineProperties(ρσ_float, {
55
81
  __module__ : {value: "__main__"}
56
82
  });
57
83
 
84
+ ρσ_float.__name__ = "float";
58
85
  function ρσ_arraylike_creator() {
59
86
  var names;
60
87
  names = "Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" ");
@@ -125,7 +152,7 @@ function ρσ_ord(x) {
125
152
  if (55296 <= ans && ans <= 56319) {
126
153
  second = x.charCodeAt(1);
127
154
  if (56320 <= second && second <= 57343) {
128
- return (ans - 55296) * 1024 + second - 56320 + 65536;
155
+ return ρσ_list_add(ρσ_list_add((ans - 55296) * 1024, second) - 56320, 65536);
129
156
  }
130
157
  throw new TypeError("string is missing the low surrogate char");
131
158
  }
@@ -141,7 +168,7 @@ function ρσ_chr(code) {
141
168
  return String.fromCharCode(code);
142
169
  }
143
170
  code -= 65536;
144
- return String.fromCharCode(55296 + (code >> 10), 56320 + (code & 1023));
171
+ return String.fromCharCode(ρσ_list_add(55296, (code >> 10)), ρσ_list_add(56320, (code & 1023)));
145
172
  };
146
173
  if (!ρσ_chr.__argnames__) Object.defineProperties(ρσ_chr, {
147
174
  __argnames__ : {value: ["code"]},
@@ -149,13 +176,42 @@ if (!ρσ_chr.__argnames__) Object.defineProperties(ρσ_chr, {
149
176
  });
150
177
 
151
178
  function ρσ_callable(x) {
152
- return typeof x === "function";
179
+ return typeof x === "function" || (x !== null && x !== undefined && typeof x.__call__ === "function");
153
180
  };
154
181
  if (!ρσ_callable.__argnames__) Object.defineProperties(ρσ_callable, {
155
182
  __argnames__ : {value: ["x"]},
156
183
  __module__ : {value: "__main__"}
157
184
  });
158
185
 
186
+ function ρσ_callable_call(fn) {
187
+ var args;
188
+ args = Array.prototype.slice.call(arguments, 1);
189
+ if (fn !== null && fn !== undefined && typeof fn.__call__ === "function") {
190
+ return fn.__call__.apply(fn, args);
191
+ }
192
+ if (typeof fn === "function") {
193
+ return fn.apply(undefined, args);
194
+ }
195
+ throw new TypeError("object is not callable");
196
+ };
197
+ if (!ρσ_callable_call.__argnames__) Object.defineProperties(ρσ_callable_call, {
198
+ __argnames__ : {value: ["fn"]},
199
+ __module__ : {value: "__main__"}
200
+ });
201
+
202
+ function ρσ_round(x, ndigits) {
203
+ var factor;
204
+ if (ndigits === undefined || ndigits === 0) {
205
+ return Math.round(x);
206
+ }
207
+ factor = Math.pow(10, ndigits);
208
+ return Math.round(x * factor) / factor;
209
+ };
210
+ if (!ρσ_round.__argnames__) Object.defineProperties(ρσ_round, {
211
+ __argnames__ : {value: ["x", "ndigits"]},
212
+ __module__ : {value: "__main__"}
213
+ });
214
+
159
215
  function ρσ_bin(x) {
160
216
  var ans;
161
217
  if (typeof x !== "number" || x % 1 !== 0) {
@@ -163,9 +219,9 @@ function ρσ_bin(x) {
163
219
  }
164
220
  ans = x.toString(2);
165
221
  if (ans[0] === "-") {
166
- ans = "-" + "0b" + ans.slice(1);
222
+ ans = ρσ_list_add(ρσ_list_add("-", "0b"), ans.slice(1));
167
223
  } else {
168
- ans = "0b" + ans;
224
+ ans = ρσ_list_add("0b", ans);
169
225
  }
170
226
  return ans;
171
227
  };
@@ -181,9 +237,9 @@ function ρσ_hex(x) {
181
237
  }
182
238
  ans = x.toString(16);
183
239
  if (ans[0] === "-") {
184
- ans = "-" + "0x" + ans.slice(1);
240
+ ans = ρσ_list_add(ρσ_list_add("-", "0x"), ans.slice(1));
185
241
  } else {
186
- ans = "0x" + ans;
242
+ ans = ρσ_list_add("0x", ans);
187
243
  }
188
244
  return ans;
189
245
  };
@@ -192,9 +248,14 @@ if (!ρσ_hex.__argnames__) Object.defineProperties(ρσ_hex, {
192
248
  __module__ : {value: "__main__"}
193
249
  });
194
250
 
195
- function ρσ_enumerate(iterable) {
196
- var ans, iterator;
197
- ans = {"_i":-1};
251
+ function ρσ_enumerate(iterable, start) {
252
+ var offset, ans, iterator;
253
+ offset = (start === undefined) ? 0 : start;
254
+ ans = (function(){
255
+ var ρσ_d = {};
256
+ ρσ_d["_i"] = offset - 1;
257
+ return ρσ_d;
258
+ }).call(this);
198
259
  ans[ρσ_iterator_symbol] = (function() {
199
260
  var ρσ_anonfunc = function () {
200
261
  return this;
@@ -207,9 +268,16 @@ function ρσ_enumerate(iterable) {
207
268
  if (ρσ_arraylike(iterable)) {
208
269
  ans["next"] = (function() {
209
270
  var ρσ_anonfunc = function () {
210
- this._i += 1;
211
- if (this._i < iterable.length) {
212
- return {'done':false, 'value':[this._i, iterable[this._i]]};
271
+ var idx;
272
+ this._i = ρσ_list_iadd(this._i, 1);
273
+ idx = this._i - offset;
274
+ if (idx < iterable.length) {
275
+ return (function(){
276
+ var ρσ_d = {};
277
+ ρσ_d["done"] = false;
278
+ ρσ_d["value"] = ρσ_list_decorate([ this._i, iterable[(typeof idx === "number" && idx < 0) ? iterable.length + idx : idx] ]);
279
+ return ρσ_d;
280
+ }).call(this);
213
281
  }
214
282
  return {'done':true};
215
283
  };
@@ -230,8 +298,13 @@ function ρσ_enumerate(iterable) {
230
298
  if (r.done) {
231
299
  return {'done':true};
232
300
  }
233
- this._i += 1;
234
- return {'done':false, 'value':[this._i, r.value]};
301
+ this._i = ρσ_list_iadd(this._i, 1);
302
+ return (function(){
303
+ var ρσ_d = {};
304
+ ρσ_d["done"] = false;
305
+ ρσ_d["value"] = ρσ_list_decorate([ this._i, r.value ]);
306
+ return ρσ_d;
307
+ }).call(this);
235
308
  };
236
309
  if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
237
310
  __module__ : {value: "__main__"}
@@ -240,10 +313,10 @@ function ρσ_enumerate(iterable) {
240
313
  })();
241
314
  return ans;
242
315
  }
243
- return ρσ_enumerate(Object.keys(iterable));
316
+ return ρσ_enumerate(Object.keys(iterable), start);
244
317
  };
245
318
  if (!ρσ_enumerate.__argnames__) Object.defineProperties(ρσ_enumerate, {
246
- __argnames__ : {value: ["iterable"]},
319
+ __argnames__ : {value: ["iterable", "start"]},
247
320
  __module__ : {value: "__main__"}
248
321
  });
249
322
 
@@ -282,8 +355,40 @@ if (!ρσ_reversed.__argnames__) Object.defineProperties(ρσ_reversed, {
282
355
  __module__ : {value: "__main__"}
283
356
  });
284
357
 
285
- function ρσ_iter(iterable) {
286
- var ans;
358
+ function ρσ_iter(iterable, sentinel) {
359
+ var callable_, ans;
360
+ if (arguments.length >= 2) {
361
+ callable_ = iterable;
362
+ ans = {"_callable":callable_,"_sentinel":sentinel,"_done":false};
363
+ ans[ρσ_iterator_symbol] = (function() {
364
+ var ρσ_anonfunc = function () {
365
+ return this;
366
+ };
367
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
368
+ __module__ : {value: "__main__"}
369
+ });
370
+ return ρσ_anonfunc;
371
+ })();
372
+ ans["next"] = (function() {
373
+ var ρσ_anonfunc = function () {
374
+ var val;
375
+ if (this._done) {
376
+ return {'done':true};
377
+ }
378
+ val = ρσ_callable_call(this._callable);
379
+ if (val === this._sentinel) {
380
+ this._done = true;
381
+ return {'done':true};
382
+ }
383
+ return {'done':false,'value':val};
384
+ };
385
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
386
+ __module__ : {value: "__main__"}
387
+ });
388
+ return ρσ_anonfunc;
389
+ })();
390
+ return ans;
391
+ }
287
392
  if (typeof iterable[ρσ_iterator_symbol] === "function") {
288
393
  return (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
289
394
  }
@@ -300,7 +405,7 @@ function ρσ_iter(iterable) {
300
405
  })();
301
406
  ans["next"] = (function() {
302
407
  var ρσ_anonfunc = function () {
303
- this._i += 1;
408
+ this._i = ρσ_list_iadd(this._i, 1);
304
409
  if (this._i < iterable.length) {
305
410
  return {'done':false, 'value':iterable[this._i]};
306
411
  }
@@ -316,14 +421,14 @@ function ρσ_iter(iterable) {
316
421
  return ρσ_iter(Object.keys(iterable));
317
422
  };
318
423
  if (!ρσ_iter.__argnames__) Object.defineProperties(ρσ_iter, {
319
- __argnames__ : {value: ["iterable"]},
424
+ __argnames__ : {value: ["iterable", "sentinel"]},
320
425
  __module__ : {value: "__main__"}
321
426
  });
322
427
 
323
428
  function ρσ_range_next(step, length) {
324
429
  var ρσ_unpack;
325
- this._i += step;
326
- this._idx += 1;
430
+ this._i = ρσ_list_iadd(this._i, step);
431
+ this._idx = ρσ_list_iadd(this._idx, 1);
327
432
  if (this._idx >= length) {
328
433
  ρσ_unpack = [this.__i, -1];
329
434
  this._i = ρσ_unpack[0];
@@ -404,7 +509,7 @@ function ρσ_range(start, stop, step) {
404
509
  })();
405
510
  ans.__repr__ = (function() {
406
511
  var ρσ_anonfunc = function () {
407
- return "range(" + ρσ_str.format("{}", start) + ", " + ρσ_str.format("{}", stop) + ", " + ρσ_str.format("{}", step) + ")";
512
+ return ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add("range(", ρσ_str.format("{}", start)), ", "), ρσ_str.format("{}", stop)), ", "), ρσ_str.format("{}", step)), ")");
408
513
  };
409
514
  if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
410
515
  __module__ : {value: "__main__"}
@@ -456,7 +561,7 @@ function ρσ_getattr(obj, name, defval) {
456
561
  ρσ_last_exception = ρσ_Exception;
457
562
  if (ρσ_Exception instanceof TypeError) {
458
563
  if (defval === undefined) {
459
- throw new AttributeError("The attribute " + name + " is not present");
564
+ throw new AttributeError(ρσ_list_add(ρσ_list_add("The attribute ", name), " is not present"));
460
565
  }
461
566
  return defval;
462
567
  } else {
@@ -465,7 +570,7 @@ function ρσ_getattr(obj, name, defval) {
465
570
  }
466
571
  if (ret === undefined && !(name in obj)) {
467
572
  if (defval === undefined) {
468
- throw new AttributeError("The attribute " + name + " is not present");
573
+ throw new AttributeError(ρσ_list_add(ρσ_list_add("The attribute ", name), " is not present"));
469
574
  }
470
575
  ret = defval;
471
576
  }
@@ -540,6 +645,27 @@ if (!ρσ_get_module.__argnames__) Object.defineProperties(ρσ_get_module, {
540
645
  __module__ : {value: "__main__"}
541
646
  });
542
647
 
648
+ function ρσ__import__(name, globals, locals, fromlist, level) {
649
+ var lookup, module;
650
+ if (typeof ρσ_modules === "undefined") {
651
+ throw ImportError(ρσ_list_add(ρσ_list_add("No module named '", name), "'"));
652
+ }
653
+ if (fromlist !== undefined && fromlist !== null && fromlist.length) {
654
+ lookup = name;
655
+ } else {
656
+ lookup = name.split(".")[0];
657
+ }
658
+ module = ρσ_modules[(typeof lookup === "number" && lookup < 0) ? ρσ_modules.length + lookup : lookup];
659
+ if (module === undefined) {
660
+ throw ModuleNotFoundError(ρσ_list_add(ρσ_list_add("No module named '", lookup), "'"));
661
+ }
662
+ return module;
663
+ };
664
+ if (!ρσ__import__.__argnames__) Object.defineProperties(ρσ__import__, {
665
+ __argnames__ : {value: ["name", "globals", "locals", "fromlist", "level"]},
666
+ __module__ : {value: "__main__"}
667
+ });
668
+
543
669
  function ρσ_pow(x, y, z) {
544
670
  var ans;
545
671
  ans = Math.pow(x, y);
@@ -561,6 +687,101 @@ if (!ρσ_type.__argnames__) Object.defineProperties(ρσ_type, {
561
687
  __module__ : {value: "__main__"}
562
688
  });
563
689
 
690
+ function ρσ_issubclass(cls, base) {
691
+ var b;
692
+ if (Array.isArray(base)) {
693
+ var ρσ_Iter0 = ρσ_Iterable(base);
694
+ for (var ρσ_Index0 = 0; ρσ_Index0 < ρσ_Iter0.length; ρσ_Index0++) {
695
+ b = ρσ_Iter0[ρσ_Index0];
696
+ if (ρσ_issubclass(cls, b)) {
697
+ return true;
698
+ }
699
+ }
700
+ return false;
701
+ }
702
+ if (typeof cls !== "function") {
703
+ throw new TypeError("issubclass() arg 1 must be a class");
704
+ }
705
+ if (typeof base !== "function") {
706
+ throw new TypeError("issubclass() arg 2 must be a class");
707
+ }
708
+ if (cls === base) {
709
+ return true;
710
+ }
711
+ var proto = cls.prototype; while (proto !== null && proto !== undefined) { if (proto === base.prototype) return true; proto = Object.getPrototypeOf(proto); };
712
+ return false;
713
+ };
714
+ if (!ρσ_issubclass.__argnames__) Object.defineProperties(ρσ_issubclass, {
715
+ __argnames__ : {value: ["cls", "base"]},
716
+ __module__ : {value: "__main__"}
717
+ });
718
+
719
+ var ρσ_hash_id_counter = 0;
720
+ function ρσ_hash(obj) {
721
+ var ρσ_t = typeof obj;
722
+ if (obj === null || obj === undefined) return 0;
723
+ if (ρσ_t === "boolean") return obj ? 1 : 0;
724
+ if (ρσ_t === "number") { return (obj === Math.floor(obj)) ? (obj | 0) : ((obj * 2654435761) | 0); };
725
+ if (ρσ_t === "string") {
726
+ var ρσ_h = 5381;
727
+ for (var ρσ_i = 0; ρσ_i < obj.length; ρσ_i++) {
728
+ ρσ_h = (((ρσ_h << 5) + ρσ_h) ^ obj.charCodeAt(ρσ_i)) | 0;
729
+ }
730
+ return ρσ_h;
731
+ };
732
+ if (obj.__hash__ === null) throw new TypeError("unhashable type: '" + (obj.constructor && obj.constructor.name ? obj.constructor.name : "object") + "'");
733
+ if (typeof obj.__hash__ === "function") return obj.__hash__();
734
+ if (Array.isArray(obj)) throw new TypeError("unhashable type: 'list'");
735
+ if (typeof ρσ_set === "function" && obj instanceof ρσ_set) throw new TypeError("unhashable type: 'set'");
736
+ if (typeof Set === "function" && obj instanceof Set) throw new TypeError("unhashable type: 'set'");
737
+ if (typeof ρσ_dict === "function" && obj instanceof ρσ_dict) throw new TypeError("unhashable type: 'dict'");
738
+ if (typeof Map === "function" && obj instanceof Map) throw new TypeError("unhashable type: 'dict'");
739
+ if (!obj.constructor || obj.constructor === Object) throw new TypeError("unhashable type: 'dict'");
740
+ if (obj.ρσ_object_id === undefined) obj.ρσ_object_id = ++ρσ_hash_id_counter;
741
+ return obj.ρσ_object_id;
742
+ };
743
+ if (!ρσ_hash.__argnames__) Object.defineProperties(ρσ_hash, {
744
+ __argnames__ : {value: ["obj"]},
745
+ __module__ : {value: "__main__"}
746
+ });
747
+
748
+ function ρσ_next(iterator, defval) {
749
+ var r;
750
+ if (iterator === null || iterator === undefined) {
751
+ throw new TypeError("object is not an iterator");
752
+ }
753
+ if (typeof iterator.next === "function") {
754
+ r = iterator.next();
755
+ if (r.done) {
756
+ if (arguments.length > 1) {
757
+ return defval;
758
+ }
759
+ throw StopIteration();
760
+ }
761
+ return r.value;
762
+ }
763
+ if (typeof iterator.__next__ === "function") {
764
+ try {
765
+ return iterator.__next__();
766
+ } catch (ρσ_Exception) {
767
+ ρσ_last_exception = ρσ_Exception;
768
+ if (ρσ_Exception instanceof StopIteration) {
769
+ if (arguments.length > 1) {
770
+ return defval;
771
+ }
772
+ throw ρσ_Exception;
773
+ } else {
774
+ throw ρσ_Exception;
775
+ }
776
+ }
777
+ }
778
+ throw new TypeError("object is not an iterator");
779
+ };
780
+ if (!ρσ_next.__argnames__) Object.defineProperties(ρσ_next, {
781
+ __argnames__ : {value: ["iterator", "defval"]},
782
+ __module__ : {value: "__main__"}
783
+ });
784
+
564
785
  function ρσ_divmod(x, y) {
565
786
  var d;
566
787
  if (y === 0) {
@@ -579,6 +800,7 @@ function ρσ_max() {
579
800
  if (kwargs === null || typeof kwargs !== "object" || kwargs [ρσ_kwargs_symbol] !== true) kwargs = {};
580
801
  var args = Array.prototype.slice.call(arguments, 0);
581
802
  if (kwargs !== null && typeof kwargs === "object" && kwargs [ρσ_kwargs_symbol] === true) args.pop();
803
+ kwargs = ρσ_kwargs_to_dict(kwargs);
582
804
  var args, x;
583
805
  if (args.length === 0) {
584
806
  if (kwargs.defval !== undefined) {
@@ -616,12 +838,124 @@ if (!ρσ_max.__handles_kwarg_interpolation__) Object.defineProperties(ρσ_max,
616
838
  __module__ : {value: "__main__"}
617
839
  });
618
840
 
841
+ function ρσ_slice() {
842
+ if (!(this instanceof ρσ_slice)) return new ρσ_slice(...arguments);
843
+ if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
844
+ ρσ_slice.prototype.__init__.apply(this, arguments);
845
+ }
846
+ ρσ_slice.prototype.__init__ = function __init__(start_or_stop, stop, step) {
847
+ var self = this;
848
+ if (arguments.length === 1) {
849
+ self.start = null;
850
+ self.stop = start_or_stop;
851
+ self.step = null;
852
+ } else if (arguments.length === 2) {
853
+ self.start = start_or_stop;
854
+ self.stop = stop;
855
+ self.step = null;
856
+ } else {
857
+ self.start = start_or_stop;
858
+ self.stop = stop;
859
+ self.step = step;
860
+ }
861
+ };
862
+ if (!ρσ_slice.prototype.__init__.__argnames__) Object.defineProperties(ρσ_slice.prototype.__init__, {
863
+ __argnames__ : {value: ["start_or_stop", "stop", "step"]},
864
+ __module__ : {value: "__main__"}
865
+ });
866
+ ρσ_slice.__argnames__ = ρσ_slice.prototype.__init__.__argnames__;
867
+ ρσ_slice.__handles_kwarg_interpolation__ = ρσ_slice.prototype.__init__.__handles_kwarg_interpolation__;
868
+ ρσ_slice.prototype.indices = function indices(length) {
869
+ var self = this;
870
+ var step, lower, upper, start, stop;
871
+ step = (self.step === null) ? 1 : self.step;
872
+ if (step === 0) {
873
+ throw new ValueError("slice step cannot be zero");
874
+ }
875
+ if (step > 0) {
876
+ lower = 0;
877
+ upper = length;
878
+ start = (self.start === null) ? lower : self.start;
879
+ stop = (self.stop === null) ? upper : self.stop;
880
+ } else {
881
+ lower = -1;
882
+ upper = length - 1;
883
+ start = (self.start === null) ? upper : self.start;
884
+ stop = (self.stop === null) ? lower : self.stop;
885
+ }
886
+ if (self.start !== null) {
887
+ if (start < 0) {
888
+ start = max(ρσ_list_add(start, length), lower);
889
+ }
890
+ if (start > upper) {
891
+ start = upper;
892
+ }
893
+ }
894
+ if (self.stop !== null) {
895
+ if (stop < 0) {
896
+ stop = max(ρσ_list_add(stop, length), lower);
897
+ }
898
+ if (stop > upper) {
899
+ stop = upper;
900
+ }
901
+ }
902
+ return [start, stop, step];
903
+ };
904
+ if (!ρσ_slice.prototype.indices.__argnames__) Object.defineProperties(ρσ_slice.prototype.indices, {
905
+ __argnames__ : {value: ["length"]},
906
+ __module__ : {value: "__main__"}
907
+ });
908
+ ρσ_slice.prototype.__repr__ = function __repr__() {
909
+ var self = this;
910
+ var s, stop, step;
911
+ s = (self.start === null) ? "None" : new String(self.start);
912
+ stop = (self.stop === null) ? "None" : new String(self.stop);
913
+ step = (self.step === null) ? "None" : new String(self.step);
914
+ return ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add("slice(", s), ", "), stop), ", "), step), ")");
915
+ };
916
+ if (!ρσ_slice.prototype.__repr__.__module__) Object.defineProperties(ρσ_slice.prototype.__repr__, {
917
+ __module__ : {value: "__main__"}
918
+ });
919
+ ρσ_slice.prototype.__str__ = function __str__() {
920
+ var self = this;
921
+ return self.__repr__();
922
+ };
923
+ if (!ρσ_slice.prototype.__str__.__module__) Object.defineProperties(ρσ_slice.prototype.__str__, {
924
+ __module__ : {value: "__main__"}
925
+ });
926
+ ρσ_slice.prototype.__eq__ = function __eq__(other) {
927
+ var self = this;
928
+ if (!other instanceof ρσ_slice) {
929
+ return false;
930
+ }
931
+ return self.start === other.start && self.stop === other.stop && self.step === other.step;
932
+ };
933
+ if (!ρσ_slice.prototype.__eq__.__argnames__) Object.defineProperties(ρσ_slice.prototype.__eq__, {
934
+ __argnames__ : {value: ["other"]},
935
+ __module__ : {value: "__main__"}
936
+ });
937
+ ρσ_slice.prototype.__hash__ = function __hash__() {
938
+ var self = this;
939
+ throw new TypeError("unhashable type: 'slice'");
940
+ };
941
+ if (!ρσ_slice.prototype.__hash__.__module__) Object.defineProperties(ρσ_slice.prototype.__hash__, {
942
+ __module__ : {value: "__main__"}
943
+ });
944
+ Object.defineProperty(ρσ_slice.prototype, "__bases__", {value: []});
945
+ ρσ_slice.__name__ = "ρσ_slice";
946
+ ρσ_slice.__qualname__ = "ρσ_slice";
947
+ ρσ_slice.__module__ = "__main__";
948
+ Object.defineProperty(ρσ_slice.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
949
+
619
950
  var abs = Math.abs, max = ρσ_max.bind(Math.max), min = ρσ_max.bind(Math.min), bool = ρσ_bool, type = ρσ_type;
620
951
  var float = ρσ_float, int = ρσ_int, arraylike = ρσ_arraylike_creator(), ρσ_arraylike = arraylike;
621
- var print = ρσ_print, id = ρσ_id, get_module = ρσ_get_module, pow = ρσ_pow, divmod = ρσ_divmod;
622
- var dir = ρσ_dir, ord = ρσ_ord, chr = ρσ_chr, bin = ρσ_bin, hex = ρσ_hex, callable = ρσ_callable;
952
+ var id = ρσ_id, get_module = ρσ_get_module, pow = ρσ_pow, divmod = ρσ_divmod, __import__ = ρσ__import__;
953
+ var dir = ρσ_dir, ord = ρσ_ord, chr = ρσ_chr, bin = ρσ_bin, hex = ρσ_hex, callable = ρσ_callable, round = ρσ_round;
623
954
  var enumerate = ρσ_enumerate, iter = ρσ_iter, reversed = ρσ_reversed, len = ρσ_len;
624
- var range = ρσ_range, getattr = ρσ_getattr, setattr = ρσ_setattr, hasattr = ρσ_hasattr;function ρσ_equals(a, b) {
955
+ var range = ρσ_range, getattr = ρσ_getattr, setattr = ρσ_setattr, hasattr = ρσ_hasattr, issubclass = ρσ_issubclass, hash = ρσ_hash, next = ρσ_next;
956
+ var ρσ_Ellipsis = Object.freeze({toString: function(){return "Ellipsis";}, __repr__: function(){return "Ellipsis";}});
957
+ var Ellipsis = ρσ_Ellipsis;
958
+ var slice = ρσ_slice;function ρσ_equals(a, b) {
625
959
  var ρσ_unpack, akeys, bkeys, key;
626
960
  if (a === b) {
627
961
  return true;
@@ -687,9 +1021,9 @@ function ρσ_list_extend(iterable) {
687
1021
  var start, iterator, result;
688
1022
  if (Array.isArray(iterable) || typeof iterable === "string") {
689
1023
  start = this.length;
690
- this.length += iterable.length;
1024
+ this.length = ρσ_list_iadd(this.length, iterable.length);
691
1025
  for (var i = 0; i < iterable.length; i++) {
692
- (ρσ_expr_temp = this)[ρσ_bound_index(start + i, ρσ_expr_temp)] = iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i];
1026
+ (ρσ_expr_temp = this)[ρσ_bound_index(ρσ_list_add(start, i), ρσ_expr_temp)] = iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i];
693
1027
  }
694
1028
  } else {
695
1029
  iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
@@ -706,30 +1040,25 @@ if (!ρσ_list_extend.__argnames__) Object.defineProperties(ρσ_list_extend, {
706
1040
  });
707
1041
 
708
1042
  function ρσ_list_index(val, start, stop) {
709
- var idx;
710
1043
  start = start || 0;
711
1044
  if (start < 0) {
712
- start = this.length + start;
1045
+ start = ρσ_list_add(this.length, start);
713
1046
  }
714
1047
  if (start < 0) {
715
- throw new ValueError(val + " is not in list");
1048
+ throw new ValueError(ρσ_list_add(val, " is not in list"));
716
1049
  }
717
1050
  if (stop === undefined) {
718
- idx = this.indexOf(val, start);
719
- if (idx === -1) {
720
- throw new ValueError(val + " is not in list");
721
- }
722
- return idx;
1051
+ stop = this.length;
723
1052
  }
724
1053
  if (stop < 0) {
725
- stop = this.length + stop;
1054
+ stop = ρσ_list_add(this.length, stop);
726
1055
  }
727
1056
  for (var i = start; i < stop; i++) {
728
1057
  if (((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === val || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], val))) {
729
1058
  return i;
730
1059
  }
731
1060
  }
732
- throw new ValueError(val + " is not in list");
1061
+ throw new ValueError(ρσ_list_add(val, " is not in list"));
733
1062
  };
734
1063
  if (!ρσ_list_index.__argnames__) Object.defineProperties(ρσ_list_index, {
735
1064
  __argnames__ : {value: ["val", "start", "stop"]},
@@ -756,12 +1085,13 @@ if (!ρσ_list_pop.__argnames__) Object.defineProperties(ρσ_list_pop, {
756
1085
  });
757
1086
 
758
1087
  function ρσ_list_remove(value) {
759
- var idx;
760
- idx = this.indexOf(value);
761
- if (idx === -1) {
762
- throw new ValueError(value + " not in list");
1088
+ for (var i = 0; i < this.length; i++) {
1089
+ if (((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === value || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], value))) {
1090
+ this.splice(i, 1);
1091
+ return;
1092
+ }
763
1093
  }
764
- this.splice(idx, 1);
1094
+ throw new ValueError(ρσ_list_add(value, " not in list"));
765
1095
  };
766
1096
  if (!ρσ_list_remove.__argnames__) Object.defineProperties(ρσ_list_remove, {
767
1097
  __argnames__ : {value: ["value"]},
@@ -769,7 +1099,7 @@ if (!ρσ_list_remove.__argnames__) Object.defineProperties(ρσ_list_remove, {
769
1099
  });
770
1100
 
771
1101
  function ρσ_list_to_string() {
772
- return "[" + this.join(", ") + "]";
1102
+ return ρσ_list_add(ρσ_list_add("[", this.join(", ")), "]");
773
1103
  };
774
1104
  if (!ρσ_list_to_string.__module__) Object.defineProperties(ρσ_list_to_string, {
775
1105
  __module__ : {value: "__main__"}
@@ -777,7 +1107,7 @@ if (!ρσ_list_to_string.__module__) Object.defineProperties(ρσ_list_to_string
777
1107
 
778
1108
  function ρσ_list_insert(index, val) {
779
1109
  if (index < 0) {
780
- index += this.length;
1110
+ index = ρσ_list_iadd(index, this.length);
781
1111
  }
782
1112
  index = min(this.length, max(index, 0));
783
1113
  if (index === 0) {
@@ -818,7 +1148,7 @@ if (!ρσ_list_as_array.__module__) Object.defineProperties(ρσ_list_as_array,
818
1148
  function ρσ_list_count(value) {
819
1149
  return this.reduce((function() {
820
1150
  var ρσ_anonfunc = function (n, val) {
821
- return n + (val === value);
1151
+ return ρσ_list_add(n, (val === value));
822
1152
  };
823
1153
  if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
824
1154
  __argnames__ : {value: ["n", "val"]},
@@ -880,7 +1210,7 @@ function ρσ_list_sort() {
880
1210
  keymap.set(k, key(k));
881
1211
  posmap.set(k, i);
882
1212
  }
883
- this.sort((function() {
1213
+ Array.prototype.sort.call(this, (function() {
884
1214
  var ρσ_anonfunc = function (a, b) {
885
1215
  return mult * ρσ_list_sort_cmp(keymap.get(a), keymap.get(b), posmap.get(a), posmap.get(b));
886
1216
  };
@@ -927,7 +1257,7 @@ function ρσ_list_iterator(value) {
927
1257
  ρσ_d["_list"] = self;
928
1258
  ρσ_d["next"] = (function() {
929
1259
  var ρσ_anonfunc = function () {
930
- this._i += 1;
1260
+ this._i = ρσ_list_iadd(this._i, 1);
931
1261
  if (this._i >= this._list.length) {
932
1262
  return (function(){
933
1263
  var ρσ_d = {};
@@ -1000,6 +1330,8 @@ function ρσ_list_decorate(ans) {
1000
1330
  ans.inspect = ρσ_list_to_string;
1001
1331
  ans.extend = ρσ_list_extend;
1002
1332
  ans.index = ρσ_list_index;
1333
+ ans.jspop = Array.prototype.pop;
1334
+ ans.pop = ρσ_list_pop;
1003
1335
  ans.pypop = ρσ_list_pop;
1004
1336
  ans.remove = ρσ_list_remove;
1005
1337
  ans.insert = ρσ_list_insert;
@@ -1007,6 +1339,8 @@ function ρσ_list_decorate(ans) {
1007
1339
  ans.clear = ρσ_list_clear;
1008
1340
  ans.count = ρσ_list_count;
1009
1341
  ans.concat = ρσ_list_concat;
1342
+ ans.jssort = Array.prototype.sort;
1343
+ ans.sort = ρσ_list_sort;
1010
1344
  ans.pysort = ρσ_list_sort;
1011
1345
  ans.slice = ρσ_list_slice;
1012
1346
  ans.as_array = ρσ_list_as_array;
@@ -1069,7 +1403,7 @@ function sorted() {
1069
1403
  }
1070
1404
  var ans;
1071
1405
  ans = ρσ_list_constructor(iterable);
1072
- ans.pysort(key, reverse);
1406
+ ans.sort(key, reverse);
1073
1407
  return ans;
1074
1408
  };
1075
1409
  if (!sorted.__defaults__) Object.defineProperties(sorted, {
@@ -1079,12 +1413,39 @@ if (!sorted.__defaults__) Object.defineProperties(sorted, {
1079
1413
  __module__ : {value: "__main__"}
1080
1414
  });
1081
1415
 
1416
+ function ρσ_tuple_constructor(iterable) {
1417
+ var iterator, ans, result;
1418
+ if (iterable === undefined) {
1419
+ return [];
1420
+ }
1421
+ if (ρσ_arraylike(iterable)) {
1422
+ return Array.prototype.slice.call(iterable);
1423
+ }
1424
+ if (typeof iterable[ρσ_iterator_symbol] === "function") {
1425
+ iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
1426
+ ans = ρσ_list_decorate([]);
1427
+ result = iterator.next();
1428
+ while (!result.done) {
1429
+ ans.push(result.value);
1430
+ result = iterator.next();
1431
+ }
1432
+ return ans;
1433
+ }
1434
+ return Object.keys(iterable);
1435
+ };
1436
+ if (!ρσ_tuple_constructor.__argnames__) Object.defineProperties(ρσ_tuple_constructor, {
1437
+ __argnames__ : {value: ["iterable"]},
1438
+ __module__ : {value: "__main__"}
1439
+ });
1440
+
1441
+ ρσ_tuple_constructor.__name__ = "tuple";
1442
+ var tuple = ρσ_tuple_constructor;
1082
1443
  var ρσ_global_object_id = 0, ρσ_set_implementation;
1083
1444
  function ρσ_set_keyfor(x) {
1084
1445
  var t, ans;
1085
1446
  t = typeof x;
1086
1447
  if (t === "string" || t === "number" || t === "boolean") {
1087
- return "_" + t[0] + x;
1448
+ return ρσ_list_add(ρσ_list_add("_", t[0]), x);
1088
1449
  }
1089
1450
  if (x === null) {
1090
1451
  return "__!@#$0";
@@ -1118,7 +1479,7 @@ if (!ρσ_set_polyfill.__module__) Object.defineProperties(ρσ_set_polyfill, {
1118
1479
  var key;
1119
1480
  key = ρσ_set_keyfor(x);
1120
1481
  if (!Object.prototype.hasOwnProperty.call(this._store, key)) {
1121
- this.size += 1;
1482
+ this.size = ρσ_list_iadd(this.size, 1);
1122
1483
  (ρσ_expr_temp = this._store)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = x;
1123
1484
  }
1124
1485
  return this;
@@ -1182,7 +1543,7 @@ if (!ρσ_set_polyfill.__module__) Object.defineProperties(ρσ_set_polyfill, {
1182
1543
  })();
1183
1544
  ans["next"] = (function() {
1184
1545
  var ρσ_anonfunc = function () {
1185
- this._i += 1;
1546
+ this._i = ρσ_list_iadd(this._i, 1);
1186
1547
  if (this._i >= this._keys.length) {
1187
1548
  return {'done': true};
1188
1549
  }
@@ -1591,7 +1952,7 @@ Object.defineProperties(ρσ_set.prototype, (function(){
1591
1952
  })();
1592
1953
  ρσ_set.prototype.toString = ρσ_set.prototype.__repr__ = ρσ_set.prototype.__str__ = ρσ_set.prototype.inspect = (function() {
1593
1954
  var ρσ_anonfunc = function () {
1594
- return "{" + list(this).join(", ") + "}";
1955
+ return ρσ_list_add(ρσ_list_add("{", list(this).join(", ")), "}");
1595
1956
  };
1596
1957
  if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
1597
1958
  __module__ : {value: "__main__"}
@@ -1601,7 +1962,7 @@ Object.defineProperties(ρσ_set.prototype, (function(){
1601
1962
  ρσ_set.prototype.__eq__ = (function() {
1602
1963
  var ρσ_anonfunc = function (other) {
1603
1964
  var iterator, r;
1604
- if (!other instanceof this.constructor) {
1965
+ if (!other || !other.jsset) {
1605
1966
  return false;
1606
1967
  }
1607
1968
  if (other.size !== this.size) {
@@ -1638,35 +1999,324 @@ if (!ρσ_set_wrap.__argnames__) Object.defineProperties(ρσ_set_wrap, {
1638
1999
  });
1639
2000
 
1640
2001
  var set = ρσ_set, set_wrap = ρσ_set_wrap;
1641
- var ρσ_dict_implementation;
1642
- function ρσ_dict_polyfill() {
1643
- this._store = {};
1644
- this.size = 0;
2002
+ function ρσ_frozenset(iterable) {
2003
+ var ans, s, iterator, result, keys;
2004
+ if (this instanceof ρσ_frozenset) {
2005
+ this.jsset = new ρσ_set_implementation;
2006
+ ans = this;
2007
+ if (iterable === undefined) {
2008
+ return ans;
2009
+ }
2010
+ s = ans.jsset;
2011
+ if (ρσ_arraylike(iterable)) {
2012
+ for (var i = 0; i < iterable.length; i++) {
2013
+ s.add(iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i]);
2014
+ }
2015
+ } else if (typeof iterable[ρσ_iterator_symbol] === "function") {
2016
+ iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
2017
+ result = iterator.next();
2018
+ while (!result.done) {
2019
+ s.add(result.value);
2020
+ result = iterator.next();
2021
+ }
2022
+ } else {
2023
+ keys = Object.keys(iterable);
2024
+ for (var j=0; j < keys.length; j++) {
2025
+ s.add(keys[(typeof j === "number" && j < 0) ? keys.length + j : j]);
2026
+ }
2027
+ }
2028
+ return ans;
2029
+ } else {
2030
+ return new ρσ_frozenset(iterable);
2031
+ }
1645
2032
  };
1646
- if (!ρσ_dict_polyfill.__module__) Object.defineProperties(ρσ_dict_polyfill, {
2033
+ if (!ρσ_frozenset.__argnames__) Object.defineProperties(ρσ_frozenset, {
2034
+ __argnames__ : {value: ["iterable"]},
1647
2035
  __module__ : {value: "__main__"}
1648
2036
  });
1649
2037
 
1650
- ρσ_dict_polyfill.prototype.set = (function() {
1651
- var ρσ_anonfunc = function (x, value) {
1652
- var key;
1653
- key = ρσ_set_keyfor(x);
1654
- if (!Object.prototype.hasOwnProperty.call(this._store, key)) {
1655
- this.size += 1;
1656
- }
1657
- (ρσ_expr_temp = this._store)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = [x, value];
1658
- return this;
2038
+ ρσ_frozenset.prototype.__name__ = "frozenset";
2039
+ Object.defineProperties(ρσ_frozenset.prototype, (function(){
2040
+ var ρσ_d = {};
2041
+ ρσ_d["length"] = (function(){
2042
+ var ρσ_d = {};
2043
+ ρσ_d["get"] = (function() {
2044
+ var ρσ_anonfunc = function () {
2045
+ return this.jsset.size;
2046
+ };
2047
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2048
+ __module__ : {value: "__main__"}
2049
+ });
2050
+ return ρσ_anonfunc;
2051
+ })();
2052
+ return ρσ_d;
2053
+ }).call(this);
2054
+ ρσ_d["size"] = (function(){
2055
+ var ρσ_d = {};
2056
+ ρσ_d["get"] = (function() {
2057
+ var ρσ_anonfunc = function () {
2058
+ return this.jsset.size;
2059
+ };
2060
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2061
+ __module__ : {value: "__main__"}
2062
+ });
2063
+ return ρσ_anonfunc;
2064
+ })();
2065
+ return ρσ_d;
2066
+ }).call(this);
2067
+ return ρσ_d;
2068
+ }).call(this));
2069
+ ρσ_frozenset.prototype.__len__ = (function() {
2070
+ var ρσ_anonfunc = function () {
2071
+ return this.jsset.size;
1659
2072
  };
1660
- if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
1661
- __argnames__ : {value: ["x", "value"]},
2073
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
1662
2074
  __module__ : {value: "__main__"}
1663
2075
  });
1664
2076
  return ρσ_anonfunc;
1665
2077
  })();
1666
- ρσ_dict_polyfill.prototype.clear = (function() {
2078
+ ρσ_frozenset.prototype.has = ρσ_frozenset.prototype.__contains__ = (function() {
1667
2079
  var ρσ_anonfunc = function (x) {
1668
- this._store = {};
1669
- this.size = 0;
2080
+ return this.jsset.has(x);
2081
+ };
2082
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2083
+ __argnames__ : {value: ["x"]},
2084
+ __module__ : {value: "__main__"}
2085
+ });
2086
+ return ρσ_anonfunc;
2087
+ })();
2088
+ ρσ_frozenset.prototype.copy = (function() {
2089
+ var ρσ_anonfunc = function () {
2090
+ return ρσ_frozenset(this);
2091
+ };
2092
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2093
+ __module__ : {value: "__main__"}
2094
+ });
2095
+ return ρσ_anonfunc;
2096
+ })();
2097
+ ρσ_frozenset.prototype[ρσ_iterator_symbol] = (function() {
2098
+ var ρσ_anonfunc = function () {
2099
+ return this.jsset.values();
2100
+ };
2101
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2102
+ __module__ : {value: "__main__"}
2103
+ });
2104
+ return ρσ_anonfunc;
2105
+ })();
2106
+ ρσ_frozenset.prototype.difference = (function() {
2107
+ var ρσ_anonfunc = function () {
2108
+ var ans, s, iterator, r, x, has;
2109
+ ans = new ρσ_frozenset;
2110
+ s = ans.jsset;
2111
+ iterator = this.jsset.values();
2112
+ r = iterator.next();
2113
+ while (!r.done) {
2114
+ x = r.value;
2115
+ has = false;
2116
+ for (var i = 0; i < arguments.length; i++) {
2117
+ if (arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) {
2118
+ has = true;
2119
+ break;
2120
+ }
2121
+ }
2122
+ if (!has) {
2123
+ s.add(x);
2124
+ }
2125
+ r = iterator.next();
2126
+ }
2127
+ return ans;
2128
+ };
2129
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2130
+ __module__ : {value: "__main__"}
2131
+ });
2132
+ return ρσ_anonfunc;
2133
+ })();
2134
+ ρσ_frozenset.prototype.intersection = (function() {
2135
+ var ρσ_anonfunc = function () {
2136
+ var ans, s, iterator, r, x, has;
2137
+ ans = new ρσ_frozenset;
2138
+ s = ans.jsset;
2139
+ iterator = this.jsset.values();
2140
+ r = iterator.next();
2141
+ while (!r.done) {
2142
+ x = r.value;
2143
+ has = true;
2144
+ for (var i = 0; i < arguments.length; i++) {
2145
+ if (!arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) {
2146
+ has = false;
2147
+ break;
2148
+ }
2149
+ }
2150
+ if (has) {
2151
+ s.add(x);
2152
+ }
2153
+ r = iterator.next();
2154
+ }
2155
+ return ans;
2156
+ };
2157
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2158
+ __module__ : {value: "__main__"}
2159
+ });
2160
+ return ρσ_anonfunc;
2161
+ })();
2162
+ ρσ_frozenset.prototype.isdisjoint = (function() {
2163
+ var ρσ_anonfunc = function (other) {
2164
+ var iterator, r, x;
2165
+ iterator = this.jsset.values();
2166
+ r = iterator.next();
2167
+ while (!r.done) {
2168
+ x = r.value;
2169
+ if (other.has(x)) {
2170
+ return false;
2171
+ }
2172
+ r = iterator.next();
2173
+ }
2174
+ return true;
2175
+ };
2176
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2177
+ __argnames__ : {value: ["other"]},
2178
+ __module__ : {value: "__main__"}
2179
+ });
2180
+ return ρσ_anonfunc;
2181
+ })();
2182
+ ρσ_frozenset.prototype.issubset = (function() {
2183
+ var ρσ_anonfunc = function (other) {
2184
+ var iterator, r, x;
2185
+ iterator = this.jsset.values();
2186
+ r = iterator.next();
2187
+ while (!r.done) {
2188
+ x = r.value;
2189
+ if (!other.has(x)) {
2190
+ return false;
2191
+ }
2192
+ r = iterator.next();
2193
+ }
2194
+ return true;
2195
+ };
2196
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2197
+ __argnames__ : {value: ["other"]},
2198
+ __module__ : {value: "__main__"}
2199
+ });
2200
+ return ρσ_anonfunc;
2201
+ })();
2202
+ ρσ_frozenset.prototype.issuperset = (function() {
2203
+ var ρσ_anonfunc = function (other) {
2204
+ var s, iterator, r, x;
2205
+ s = this.jsset;
2206
+ iterator = other[ρσ_iterator_symbol]();
2207
+ r = iterator.next();
2208
+ while (!r.done) {
2209
+ x = r.value;
2210
+ if (!s.has(x)) {
2211
+ return false;
2212
+ }
2213
+ r = iterator.next();
2214
+ }
2215
+ return true;
2216
+ };
2217
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2218
+ __argnames__ : {value: ["other"]},
2219
+ __module__ : {value: "__main__"}
2220
+ });
2221
+ return ρσ_anonfunc;
2222
+ })();
2223
+ ρσ_frozenset.prototype.symmetric_difference = (function() {
2224
+ var ρσ_anonfunc = function (other) {
2225
+ return this.union(other).difference(this.intersection(other));
2226
+ };
2227
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2228
+ __argnames__ : {value: ["other"]},
2229
+ __module__ : {value: "__main__"}
2230
+ });
2231
+ return ρσ_anonfunc;
2232
+ })();
2233
+ ρσ_frozenset.prototype.union = (function() {
2234
+ var ρσ_anonfunc = function () {
2235
+ var ans, s, iterator, r;
2236
+ ans = ρσ_frozenset(this);
2237
+ s = ans.jsset;
2238
+ for (var i=0; i < arguments.length; i++) {
2239
+ iterator = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i][ρσ_iterator_symbol]();
2240
+ r = iterator.next();
2241
+ while (!r.done) {
2242
+ s.add(r.value);
2243
+ r = iterator.next();
2244
+ }
2245
+ }
2246
+ return ans;
2247
+ };
2248
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2249
+ __module__ : {value: "__main__"}
2250
+ });
2251
+ return ρσ_anonfunc;
2252
+ })();
2253
+ ρσ_frozenset.prototype.toString = ρσ_frozenset.prototype.__repr__ = ρσ_frozenset.prototype.__str__ = ρσ_frozenset.prototype.inspect = (function() {
2254
+ var ρσ_anonfunc = function () {
2255
+ return ρσ_list_add(ρσ_list_add("frozenset({", list(this).join(", ")), "})");
2256
+ };
2257
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2258
+ __module__ : {value: "__main__"}
2259
+ });
2260
+ return ρσ_anonfunc;
2261
+ })();
2262
+ ρσ_frozenset.prototype.__eq__ = (function() {
2263
+ var ρσ_anonfunc = function (other) {
2264
+ var iterator, r;
2265
+ if (!other || !other.jsset) {
2266
+ return false;
2267
+ }
2268
+ if (other.size !== this.size) {
2269
+ return false;
2270
+ }
2271
+ if (other.size === 0) {
2272
+ return true;
2273
+ }
2274
+ iterator = other[ρσ_iterator_symbol]();
2275
+ r = iterator.next();
2276
+ while (!r.done) {
2277
+ if (!this.has(r.value)) {
2278
+ return false;
2279
+ }
2280
+ r = iterator.next();
2281
+ }
2282
+ return true;
2283
+ };
2284
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2285
+ __argnames__ : {value: ["other"]},
2286
+ __module__ : {value: "__main__"}
2287
+ });
2288
+ return ρσ_anonfunc;
2289
+ })();
2290
+ var frozenset = ρσ_frozenset;
2291
+ var ρσ_dict_implementation;
2292
+ function ρσ_dict_polyfill() {
2293
+ this._store = {};
2294
+ this.size = 0;
2295
+ };
2296
+ if (!ρσ_dict_polyfill.__module__) Object.defineProperties(ρσ_dict_polyfill, {
2297
+ __module__ : {value: "__main__"}
2298
+ });
2299
+
2300
+ ρσ_dict_polyfill.prototype.set = (function() {
2301
+ var ρσ_anonfunc = function (x, value) {
2302
+ var key;
2303
+ key = ρσ_set_keyfor(x);
2304
+ if (!Object.prototype.hasOwnProperty.call(this._store, key)) {
2305
+ this.size = ρσ_list_iadd(this.size, 1);
2306
+ }
2307
+ (ρσ_expr_temp = this._store)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = [x, value];
2308
+ return this;
2309
+ };
2310
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2311
+ __argnames__ : {value: ["x", "value"]},
2312
+ __module__ : {value: "__main__"}
2313
+ });
2314
+ return ρσ_anonfunc;
2315
+ })();
2316
+ ρσ_dict_polyfill.prototype.clear = (function() {
2317
+ var ρσ_anonfunc = function (x) {
2318
+ this._store = {};
2319
+ this.size = 0;
1670
2320
  };
1671
2321
  if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
1672
2322
  __argnames__ : {value: ["x"]},
@@ -1735,7 +2385,7 @@ if (!ρσ_dict_polyfill.__module__) Object.defineProperties(ρσ_dict_polyfill,
1735
2385
  })();
1736
2386
  ans["next"] = (function() {
1737
2387
  var ρσ_anonfunc = function () {
1738
- this._i += 1;
2388
+ this._i = ρσ_list_iadd(this._i, 1);
1739
2389
  if (this._i >= this._keys.length) {
1740
2390
  return {'done': true};
1741
2391
  }
@@ -1769,7 +2419,7 @@ if (!ρσ_dict_polyfill.__module__) Object.defineProperties(ρσ_dict_polyfill,
1769
2419
  })();
1770
2420
  ans["next"] = (function() {
1771
2421
  var ρσ_anonfunc = function () {
1772
- this._i += 1;
2422
+ this._i = ρσ_list_iadd(this._i, 1);
1773
2423
  if (this._i >= this._keys.length) {
1774
2424
  return {'done': true};
1775
2425
  }
@@ -1803,7 +2453,7 @@ if (!ρσ_dict_polyfill.__module__) Object.defineProperties(ρσ_dict_polyfill,
1803
2453
  })();
1804
2454
  ans["next"] = (function() {
1805
2455
  var ρσ_anonfunc = function () {
1806
- this._i += 1;
2456
+ this._i = ρσ_list_iadd(this._i, 1);
1807
2457
  if (this._i >= this._keys.length) {
1808
2458
  return {'done': true};
1809
2459
  }
@@ -1822,6 +2472,21 @@ if (!ρσ_dict_polyfill.__module__) Object.defineProperties(ρσ_dict_polyfill,
1822
2472
  });
1823
2473
  return ρσ_anonfunc;
1824
2474
  })();
2475
+ ρσ_dict_polyfill.prototype.forEach = (function() {
2476
+ var ρσ_anonfunc = function (callback) {
2477
+ var keys, entry;
2478
+ keys = Object.keys(this._store);
2479
+ for (var ρσ_fi = 0; ρσ_fi < keys.length; ρσ_fi++) {
2480
+ entry = (ρσ_expr_temp = this._store)[ρσ_bound_index(keys[ρσ_bound_index(ρσ_fi, keys)], ρσ_expr_temp)];
2481
+ callback(entry[1], entry[0], this);
2482
+ }
2483
+ };
2484
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2485
+ __argnames__ : {value: ["callback"]},
2486
+ __module__ : {value: "__main__"}
2487
+ });
2488
+ return ρσ_anonfunc;
2489
+ })();
1825
2490
  if (typeof Map !== "function" || typeof Map.prototype.delete !== "function") {
1826
2491
  ρσ_dict_implementation = ρσ_dict_polyfill;
1827
2492
  } else {
@@ -1831,6 +2496,7 @@ function ρσ_dict() {
1831
2496
  var iterable = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0];
1832
2497
  var kw = arguments[arguments.length-1];
1833
2498
  if (kw === null || typeof kw !== "object" || kw [ρσ_kwargs_symbol] !== true) kw = {};
2499
+ kw = ρσ_kwargs_to_dict(kw);
1834
2500
  if (this instanceof ρσ_dict) {
1835
2501
  this.jsmap = new ρσ_dict_implementation;
1836
2502
  if (iterable !== undefined) {
@@ -1977,7 +2643,7 @@ Object.defineProperties(ρσ_dict.prototype, (function(){
1977
2643
  var ans;
1978
2644
  ans = this.jsmap.get(key);
1979
2645
  if (ans === undefined && !this.jsmap.has(key)) {
1980
- throw new KeyError(key + "");
2646
+ throw new KeyError(ρσ_list_add(key, ""));
1981
2647
  }
1982
2648
  return ans;
1983
2649
  };
@@ -2002,7 +2668,7 @@ Object.defineProperties(ρσ_dict.prototype, (function(){
2002
2668
  });
2003
2669
  return ρσ_anonfunc;
2004
2670
  })();
2005
- ρσ_dict.prototype.set_default = (function() {
2671
+ ρσ_dict.prototype.set_default = ρσ_dict.prototype.setdefault = (function() {
2006
2672
  var ρσ_anonfunc = function (key, defval) {
2007
2673
  var j;
2008
2674
  j = this.jsmap;
@@ -2088,7 +2754,7 @@ Object.defineProperties(ρσ_dict.prototype, (function(){
2088
2754
  })();
2089
2755
  ρσ_dict.prototype.update = (function() {
2090
2756
  var ρσ_anonfunc = function () {
2091
- var m, iterable, iterator, result, keys;
2757
+ var m, iterable, iterator, result, pairs, keys;
2092
2758
  if (arguments.length === 0) {
2093
2759
  return;
2094
2760
  }
@@ -2112,6 +2778,11 @@ Object.defineProperties(ρσ_dict.prototype, (function(){
2112
2778
  m.set(result.value[0], result.value[1]);
2113
2779
  result = iterator.next();
2114
2780
  }
2781
+ } else if (typeof iterable.items === "function" && !Array.isArray(iterable)) {
2782
+ pairs = iterable.items();
2783
+ for (var k2 = 0; k2 < pairs.length; k2++) {
2784
+ m.set(pairs[(typeof k2 === "number" && k2 < 0) ? pairs.length + k2 : k2][0], pairs[(typeof k2 === "number" && k2 < 0) ? pairs.length + k2 : k2][1]);
2785
+ }
2115
2786
  } else if (typeof iterable[ρσ_iterator_symbol] === "function") {
2116
2787
  iterator = iterable[ρσ_iterator_symbol]();
2117
2788
  result = iterator.next();
@@ -2143,10 +2814,10 @@ Object.defineProperties(ρσ_dict.prototype, (function(){
2143
2814
  iterator = this.jsmap.entries();
2144
2815
  r = iterator.next();
2145
2816
  while (!r.done) {
2146
- entries.push(ρσ_repr(r.value[0]) + ": " + ρσ_repr(r.value[1]));
2817
+ entries.push(ρσ_list_add(ρσ_list_add(ρσ_repr(r.value[0]), ": "), ρσ_repr(r.value[1])));
2147
2818
  r = iterator.next();
2148
2819
  }
2149
- return "{" + entries.join(", ") + "}";
2820
+ return ρσ_list_add(ρσ_list_add("{", entries.join(", ")), "}");
2150
2821
  };
2151
2822
  if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2152
2823
  __module__ : {value: "__main__"}
@@ -2182,6 +2853,30 @@ Object.defineProperties(ρσ_dict.prototype, (function(){
2182
2853
  });
2183
2854
  return ρσ_anonfunc;
2184
2855
  })();
2856
+ ρσ_dict.prototype.__or__ = (function() {
2857
+ var ρσ_anonfunc = function (other) {
2858
+ var result;
2859
+ result = ρσ_dict(this);
2860
+ result.update(other);
2861
+ return result;
2862
+ };
2863
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2864
+ __argnames__ : {value: ["other"]},
2865
+ __module__ : {value: "__main__"}
2866
+ });
2867
+ return ρσ_anonfunc;
2868
+ })();
2869
+ ρσ_dict.prototype.__ior__ = (function() {
2870
+ var ρσ_anonfunc = function (other) {
2871
+ this.update(other);
2872
+ return this;
2873
+ };
2874
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2875
+ __argnames__ : {value: ["other"]},
2876
+ __module__ : {value: "__main__"}
2877
+ });
2878
+ return ρσ_anonfunc;
2879
+ })();
2185
2880
  ρσ_dict.prototype.as_object = (function() {
2186
2881
  var ρσ_anonfunc = function (other) {
2187
2882
  var ans, iterator, r;
@@ -2200,21 +2895,101 @@ Object.defineProperties(ρσ_dict.prototype, (function(){
2200
2895
  });
2201
2896
  return ρσ_anonfunc;
2202
2897
  })();
2203
- function ρσ_dict_wrap(x) {
2204
- var ans;
2205
- ans = new ρσ_dict;
2206
- ans.jsmap = x;
2207
- return ans;
2208
- };
2209
- if (!ρσ_dict_wrap.__argnames__) Object.defineProperties(ρσ_dict_wrap, {
2210
- __argnames__ : {value: ["x"]},
2211
- __module__ : {value: "__main__"}
2212
- });
2898
+ ρσ_dict.prototype.toJSON = (function() {
2899
+ var ρσ_anonfunc = function () {
2900
+ var ans, iterator, r;
2901
+ ans = {};
2902
+ iterator = this.jsmap.entries();
2903
+ r = iterator.next();
2904
+ while (!r.done) {
2905
+ ans[ρσ_bound_index(r.value[0], ans)] = r.value[1];
2906
+ r = iterator.next();
2907
+ }
2908
+ return ans;
2909
+ };
2910
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
2911
+ __module__ : {value: "__main__"}
2912
+ });
2913
+ return ρσ_anonfunc;
2914
+ })();
2915
+ function ρσ_dict_wrap(x) {
2916
+ var ans;
2917
+ ans = new ρσ_dict;
2918
+ ans.jsmap = x;
2919
+ return ans;
2920
+ };
2921
+ if (!ρσ_dict_wrap.__argnames__) Object.defineProperties(ρσ_dict_wrap, {
2922
+ __argnames__ : {value: ["x"]},
2923
+ __module__ : {value: "__main__"}
2924
+ });
2925
+
2926
+ var dict = ρσ_dict, dict_wrap = ρσ_dict_wrap;
2213
2927
 
2214
- var dict = ρσ_dict, dict_wrap = ρσ_dict_wrap;// }}}
2215
- var NameError;
2928
+ function ρσ_kwargs_to_dict(kw) {
2929
+ // Augment the plain kwargs object with non-enumerable Python dict methods so
2930
+ // that kw.items(), kw.keys(), kw.values() work in user code, while plain
2931
+ // property access (kw.propname) and Object.keys(kw) are unaffected.
2932
+ //
2933
+ // items/keys/values return dual-mode arrays: they support both Array indexing
2934
+ // (for ρσ_dict.prototype.update which does pairs[i]) and iterator protocol
2935
+ // (for `for k, v in kw.items():` which calls .next()).
2936
+ function _make_seq(arr) {
2937
+ arr._ρσ_i = 0;
2938
+ arr.next = function() {
2939
+ return this._ρσ_i < this.length
2940
+ ? {done: false, value: this[this._ρσ_i++]}
2941
+ : {done: true, value: undefined};
2942
+ };
2943
+ arr[ρσ_iterator_symbol] = function() { this._ρσ_i = 0; return this; };
2944
+ return arr;
2945
+ }
2946
+ function _def(name, fn) {
2947
+ if (!Object.prototype.hasOwnProperty.call(kw, name)) {
2948
+ Object.defineProperty(kw, name, {value: fn, configurable: true, writable: true, enumerable: false});
2949
+ }
2950
+ }
2951
+ _def("items", function() {
2952
+ var ks = Object.keys(kw), arr = [], i;
2953
+ for (i = 0; i < ks.length; i++) arr.push([ks[i], kw[ks[i]]]);
2954
+ return _make_seq(arr);
2955
+ });
2956
+ _def("entries", kw.items);
2957
+ _def("keys", function() {
2958
+ return _make_seq(Object.keys(kw).slice());
2959
+ });
2960
+ _def("values", function() {
2961
+ var ks = Object.keys(kw), arr = [], i;
2962
+ for (i = 0; i < ks.length; i++) arr.push(kw[ks[i]]);
2963
+ return _make_seq(arr);
2964
+ });
2965
+ _def("get", function(k, d) {
2966
+ return Object.prototype.hasOwnProperty.call(kw, k) ? kw[k] : (d !== undefined ? d : null);
2967
+ });
2968
+ _def("__contains__", function(k) { return Object.prototype.hasOwnProperty.call(kw, k); });
2969
+ _def("has", function(k) { return Object.prototype.hasOwnProperty.call(kw, k); });
2970
+ _def("__len__", function() { return Object.keys(kw).length; });
2971
+ kw[ρσ_iterator_symbol] = function() {
2972
+ var ks = Object.keys(kw), i = 0;
2973
+ return {next: function() {
2974
+ return i < ks.length ? {done: false, value: ks[i++]} : {done: true, value: undefined};
2975
+ }};
2976
+ };
2977
+ return kw;
2978
+ }
2979
+ ;
2980
+ var ρσ_json_parse = function(text, reviver) {
2981
+ function dict_reviver(key, value) {
2982
+ if (value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof ρσ_dict)) {
2983
+ value = ρσ_dict(value);
2984
+ }
2985
+ return reviver ? reviver.call(this, key, value) : value;
2986
+ }
2987
+ return JSON.parse(text, dict_reviver);
2988
+ };;// }}}
2989
+ let NameError;
2216
2990
  NameError = ReferenceError;
2217
2991
  function Exception() {
2992
+ if (!(this instanceof Exception)) return new Exception(...arguments);
2218
2993
  if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
2219
2994
  Exception.prototype.__init__.apply(this, arguments);
2220
2995
  }
@@ -2233,7 +3008,7 @@ Exception.__argnames__ = Exception.prototype.__init__.__argnames__;
2233
3008
  Exception.__handles_kwarg_interpolation__ = Exception.prototype.__init__.__handles_kwarg_interpolation__;
2234
3009
  Exception.prototype.__repr__ = function __repr__() {
2235
3010
  var self = this;
2236
- return self.name + ": " + self.message;
3011
+ return ρσ_list_add(ρσ_list_add(self.name, ": "), self.message);
2237
3012
  };
2238
3013
  if (!Exception.prototype.__repr__.__module__) Object.defineProperties(Exception.prototype.__repr__, {
2239
3014
  __module__ : {value: "__main__"}
@@ -2243,8 +3018,14 @@ Exception.prototype.__str__ = function __str__ () {
2243
3018
  return this.__repr__();
2244
3019
  };
2245
3020
  Object.defineProperty(Exception.prototype, "__bases__", {value: [Error]});
3021
+ Exception.__name__ = "Exception";
3022
+ Exception.__qualname__ = "Exception";
3023
+ Exception.__module__ = "__main__";
3024
+ Object.defineProperty(Exception.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3025
+ if (typeof Error.__init_subclass__ === "function") Error.__init_subclass__.call(Exception);
2246
3026
 
2247
3027
  function AttributeError() {
3028
+ if (!(this instanceof AttributeError)) return new AttributeError(...arguments);
2248
3029
  if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
2249
3030
  AttributeError.prototype.__init__.apply(this, arguments);
2250
3031
  }
@@ -2261,9 +3042,15 @@ AttributeError.prototype.__str__ = function __str__ () {
2261
3042
  return this.__repr__();
2262
3043
  };
2263
3044
  Object.defineProperty(AttributeError.prototype, "__bases__", {value: [Exception]});
3045
+ AttributeError.__name__ = "AttributeError";
3046
+ AttributeError.__qualname__ = "AttributeError";
3047
+ AttributeError.__module__ = "__main__";
3048
+ Object.defineProperty(AttributeError.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3049
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(AttributeError);
2264
3050
 
2265
3051
 
2266
3052
  function IndexError() {
3053
+ if (!(this instanceof IndexError)) return new IndexError(...arguments);
2267
3054
  if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
2268
3055
  IndexError.prototype.__init__.apply(this, arguments);
2269
3056
  }
@@ -2280,9 +3067,15 @@ IndexError.prototype.__str__ = function __str__ () {
2280
3067
  return this.__repr__();
2281
3068
  };
2282
3069
  Object.defineProperty(IndexError.prototype, "__bases__", {value: [Exception]});
3070
+ IndexError.__name__ = "IndexError";
3071
+ IndexError.__qualname__ = "IndexError";
3072
+ IndexError.__module__ = "__main__";
3073
+ Object.defineProperty(IndexError.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3074
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(IndexError);
2283
3075
 
2284
3076
 
2285
3077
  function KeyError() {
3078
+ if (!(this instanceof KeyError)) return new KeyError(...arguments);
2286
3079
  if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
2287
3080
  KeyError.prototype.__init__.apply(this, arguments);
2288
3081
  }
@@ -2299,9 +3092,15 @@ KeyError.prototype.__str__ = function __str__ () {
2299
3092
  return this.__repr__();
2300
3093
  };
2301
3094
  Object.defineProperty(KeyError.prototype, "__bases__", {value: [Exception]});
3095
+ KeyError.__name__ = "KeyError";
3096
+ KeyError.__qualname__ = "KeyError";
3097
+ KeyError.__module__ = "__main__";
3098
+ Object.defineProperty(KeyError.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3099
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(KeyError);
2302
3100
 
2303
3101
 
2304
3102
  function ValueError() {
3103
+ if (!(this instanceof ValueError)) return new ValueError(...arguments);
2305
3104
  if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
2306
3105
  ValueError.prototype.__init__.apply(this, arguments);
2307
3106
  }
@@ -2318,9 +3117,15 @@ ValueError.prototype.__str__ = function __str__ () {
2318
3117
  return this.__repr__();
2319
3118
  };
2320
3119
  Object.defineProperty(ValueError.prototype, "__bases__", {value: [Exception]});
3120
+ ValueError.__name__ = "ValueError";
3121
+ ValueError.__qualname__ = "ValueError";
3122
+ ValueError.__module__ = "__main__";
3123
+ Object.defineProperty(ValueError.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3124
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(ValueError);
2321
3125
 
2322
3126
 
2323
3127
  function UnicodeDecodeError() {
3128
+ if (!(this instanceof UnicodeDecodeError)) return new UnicodeDecodeError(...arguments);
2324
3129
  if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
2325
3130
  UnicodeDecodeError.prototype.__init__.apply(this, arguments);
2326
3131
  }
@@ -2337,9 +3142,15 @@ UnicodeDecodeError.prototype.__str__ = function __str__ () {
2337
3142
  return this.__repr__();
2338
3143
  };
2339
3144
  Object.defineProperty(UnicodeDecodeError.prototype, "__bases__", {value: [Exception]});
3145
+ UnicodeDecodeError.__name__ = "UnicodeDecodeError";
3146
+ UnicodeDecodeError.__qualname__ = "UnicodeDecodeError";
3147
+ UnicodeDecodeError.__module__ = "__main__";
3148
+ Object.defineProperty(UnicodeDecodeError.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3149
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(UnicodeDecodeError);
2340
3150
 
2341
3151
 
2342
3152
  function AssertionError() {
3153
+ if (!(this instanceof AssertionError)) return new AssertionError(...arguments);
2343
3154
  if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
2344
3155
  AssertionError.prototype.__init__.apply(this, arguments);
2345
3156
  }
@@ -2356,9 +3167,15 @@ AssertionError.prototype.__str__ = function __str__ () {
2356
3167
  return this.__repr__();
2357
3168
  };
2358
3169
  Object.defineProperty(AssertionError.prototype, "__bases__", {value: [Exception]});
3170
+ AssertionError.__name__ = "AssertionError";
3171
+ AssertionError.__qualname__ = "AssertionError";
3172
+ AssertionError.__module__ = "__main__";
3173
+ Object.defineProperty(AssertionError.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3174
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(AssertionError);
2359
3175
 
2360
3176
 
2361
3177
  function ZeroDivisionError() {
3178
+ if (!(this instanceof ZeroDivisionError)) return new ZeroDivisionError(...arguments);
2362
3179
  if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
2363
3180
  ZeroDivisionError.prototype.__init__.apply(this, arguments);
2364
3181
  }
@@ -2375,8 +3192,256 @@ ZeroDivisionError.prototype.__str__ = function __str__ () {
2375
3192
  return this.__repr__();
2376
3193
  };
2377
3194
  Object.defineProperty(ZeroDivisionError.prototype, "__bases__", {value: [Exception]});
3195
+ ZeroDivisionError.__name__ = "ZeroDivisionError";
3196
+ ZeroDivisionError.__qualname__ = "ZeroDivisionError";
3197
+ ZeroDivisionError.__module__ = "__main__";
3198
+ Object.defineProperty(ZeroDivisionError.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3199
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(ZeroDivisionError);
2378
3200
 
2379
- var ρσ_in, ρσ_desugar_kwargs, ρσ_exists;
3201
+
3202
+ function StopIteration() {
3203
+ if (!(this instanceof StopIteration)) return new StopIteration(...arguments);
3204
+ if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
3205
+ StopIteration.prototype.__init__.apply(this, arguments);
3206
+ }
3207
+ ρσ_extends(StopIteration, Exception);
3208
+ StopIteration.prototype.__init__ = function __init__ () {
3209
+ Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments);
3210
+ };
3211
+ StopIteration.prototype.__repr__ = function __repr__ () {
3212
+ if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this);
3213
+ return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
3214
+ };
3215
+ StopIteration.prototype.__str__ = function __str__ () {
3216
+ if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
3217
+ return this.__repr__();
3218
+ };
3219
+ Object.defineProperty(StopIteration.prototype, "__bases__", {value: [Exception]});
3220
+ StopIteration.__name__ = "StopIteration";
3221
+ StopIteration.__qualname__ = "StopIteration";
3222
+ StopIteration.__module__ = "__main__";
3223
+ Object.defineProperty(StopIteration.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3224
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(StopIteration);
3225
+
3226
+
3227
+ function ImportError() {
3228
+ if (!(this instanceof ImportError)) return new ImportError(...arguments);
3229
+ if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
3230
+ ImportError.prototype.__init__.apply(this, arguments);
3231
+ }
3232
+ ρσ_extends(ImportError, Exception);
3233
+ ImportError.prototype.__init__ = function __init__ () {
3234
+ Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments);
3235
+ };
3236
+ ImportError.prototype.__repr__ = function __repr__ () {
3237
+ if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this);
3238
+ return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
3239
+ };
3240
+ ImportError.prototype.__str__ = function __str__ () {
3241
+ if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
3242
+ return this.__repr__();
3243
+ };
3244
+ Object.defineProperty(ImportError.prototype, "__bases__", {value: [Exception]});
3245
+ ImportError.__name__ = "ImportError";
3246
+ ImportError.__qualname__ = "ImportError";
3247
+ ImportError.__module__ = "__main__";
3248
+ Object.defineProperty(ImportError.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3249
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(ImportError);
3250
+
3251
+
3252
+ function ModuleNotFoundError() {
3253
+ if (!(this instanceof ModuleNotFoundError)) return new ModuleNotFoundError(...arguments);
3254
+ if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
3255
+ ModuleNotFoundError.prototype.__init__.apply(this, arguments);
3256
+ }
3257
+ ρσ_extends(ModuleNotFoundError, ImportError);
3258
+ ModuleNotFoundError.prototype.__init__ = function __init__ () {
3259
+ ImportError.prototype.__init__ && ImportError.prototype.__init__.apply(this, arguments);
3260
+ };
3261
+ ModuleNotFoundError.prototype.__repr__ = function __repr__ () {
3262
+ if(ImportError.prototype.__repr__) return ImportError.prototype.__repr__.call(this);
3263
+ return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
3264
+ };
3265
+ ModuleNotFoundError.prototype.__str__ = function __str__ () {
3266
+ if(ImportError.prototype.__str__) return ImportError.prototype.__str__.call(this);
3267
+ return this.__repr__();
3268
+ };
3269
+ Object.defineProperty(ModuleNotFoundError.prototype, "__bases__", {value: [ImportError]});
3270
+ ModuleNotFoundError.__name__ = "ModuleNotFoundError";
3271
+ ModuleNotFoundError.__qualname__ = "ModuleNotFoundError";
3272
+ ModuleNotFoundError.__module__ = "__main__";
3273
+ Object.defineProperty(ModuleNotFoundError.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3274
+ if (typeof ImportError.__init_subclass__ === "function") ImportError.__init_subclass__.call(ModuleNotFoundError);
3275
+
3276
+
3277
+ function _is_exc_class(obj) {
3278
+ return typeof obj === "function" && (obj === Error || obj.prototype && ρσ_instanceof(obj.prototype, Error));
3279
+ };
3280
+ if (!_is_exc_class.__argnames__) Object.defineProperties(_is_exc_class, {
3281
+ __argnames__ : {value: ["obj"]},
3282
+ __module__ : {value: "__main__"}
3283
+ });
3284
+
3285
+ function ExceptionGroup() {
3286
+ if (!(this instanceof ExceptionGroup)) return new ExceptionGroup(...arguments);
3287
+ if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
3288
+ ExceptionGroup.prototype.__init__.apply(this, arguments);
3289
+ }
3290
+ ρσ_extends(ExceptionGroup, Exception);
3291
+ ExceptionGroup.prototype.__init__ = function __init__(message, exceptions) {
3292
+ var self = this;
3293
+ Exception.prototype.__init__.call(self, message);
3294
+ self.exceptions = (exceptions) ? exceptions : ρσ_list_decorate([]);
3295
+ };
3296
+ if (!ExceptionGroup.prototype.__init__.__argnames__) Object.defineProperties(ExceptionGroup.prototype.__init__, {
3297
+ __argnames__ : {value: ["message", "exceptions"]},
3298
+ __module__ : {value: "__main__"}
3299
+ });
3300
+ ExceptionGroup.__argnames__ = ExceptionGroup.prototype.__init__.__argnames__;
3301
+ ExceptionGroup.__handles_kwarg_interpolation__ = ExceptionGroup.prototype.__init__.__handles_kwarg_interpolation__;
3302
+ ExceptionGroup.prototype.subgroup = function subgroup(condition) {
3303
+ var self = this;
3304
+ var matched, e;
3305
+ if (_is_exc_class(condition)) {
3306
+ matched = (function() {
3307
+ var ρσ_Iter = ρσ_Iterable(self.exceptions), ρσ_Result = [], e;
3308
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
3309
+ e = ρσ_Iter[ρσ_Index];
3310
+ if (ρσ_instanceof(e, condition)) {
3311
+ ρσ_Result.push(e);
3312
+ }
3313
+ }
3314
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
3315
+ return ρσ_Result;
3316
+ })();
3317
+ } else if (callable(condition)) {
3318
+ matched = (function() {
3319
+ var ρσ_Iter = ρσ_Iterable(self.exceptions), ρσ_Result = [], e;
3320
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
3321
+ e = ρσ_Iter[ρσ_Index];
3322
+ if (condition(e)) {
3323
+ ρσ_Result.push(e);
3324
+ }
3325
+ }
3326
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
3327
+ return ρσ_Result;
3328
+ })();
3329
+ } else {
3330
+ matched = (function() {
3331
+ var ρσ_Iter = ρσ_Iterable(self.exceptions), ρσ_Result = [], e;
3332
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
3333
+ e = ρσ_Iter[ρσ_Index];
3334
+ if (ρσ_instanceof(e, condition)) {
3335
+ ρσ_Result.push(e);
3336
+ }
3337
+ }
3338
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
3339
+ return ρσ_Result;
3340
+ })();
3341
+ }
3342
+ return (matched) ? new ExceptionGroup(self.message, matched) : null;
3343
+ };
3344
+ if (!ExceptionGroup.prototype.subgroup.__argnames__) Object.defineProperties(ExceptionGroup.prototype.subgroup, {
3345
+ __argnames__ : {value: ["condition"]},
3346
+ __module__ : {value: "__main__"}
3347
+ });
3348
+ ExceptionGroup.prototype.split = function split(condition) {
3349
+ var self = this;
3350
+ var matched, e, rest;
3351
+ if (_is_exc_class(condition)) {
3352
+ matched = (function() {
3353
+ var ρσ_Iter = ρσ_Iterable(self.exceptions), ρσ_Result = [], e;
3354
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
3355
+ e = ρσ_Iter[ρσ_Index];
3356
+ if (ρσ_instanceof(e, condition)) {
3357
+ ρσ_Result.push(e);
3358
+ }
3359
+ }
3360
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
3361
+ return ρσ_Result;
3362
+ })();
3363
+ rest = (function() {
3364
+ var ρσ_Iter = ρσ_Iterable(self.exceptions), ρσ_Result = [], e;
3365
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
3366
+ e = ρσ_Iter[ρσ_Index];
3367
+ if (!(ρσ_instanceof(e, condition))) {
3368
+ ρσ_Result.push(e);
3369
+ }
3370
+ }
3371
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
3372
+ return ρσ_Result;
3373
+ })();
3374
+ } else if (callable(condition)) {
3375
+ matched = (function() {
3376
+ var ρσ_Iter = ρσ_Iterable(self.exceptions), ρσ_Result = [], e;
3377
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
3378
+ e = ρσ_Iter[ρσ_Index];
3379
+ if (condition(e)) {
3380
+ ρσ_Result.push(e);
3381
+ }
3382
+ }
3383
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
3384
+ return ρσ_Result;
3385
+ })();
3386
+ rest = (function() {
3387
+ var ρσ_Iter = ρσ_Iterable(self.exceptions), ρσ_Result = [], e;
3388
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
3389
+ e = ρσ_Iter[ρσ_Index];
3390
+ if (!condition(e)) {
3391
+ ρσ_Result.push(e);
3392
+ }
3393
+ }
3394
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
3395
+ return ρσ_Result;
3396
+ })();
3397
+ } else {
3398
+ matched = (function() {
3399
+ var ρσ_Iter = ρσ_Iterable(self.exceptions), ρσ_Result = [], e;
3400
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
3401
+ e = ρσ_Iter[ρσ_Index];
3402
+ if (ρσ_instanceof(e, condition)) {
3403
+ ρσ_Result.push(e);
3404
+ }
3405
+ }
3406
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
3407
+ return ρσ_Result;
3408
+ })();
3409
+ rest = (function() {
3410
+ var ρσ_Iter = ρσ_Iterable(self.exceptions), ρσ_Result = [], e;
3411
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
3412
+ e = ρσ_Iter[ρσ_Index];
3413
+ if (!(ρσ_instanceof(e, condition))) {
3414
+ ρσ_Result.push(e);
3415
+ }
3416
+ }
3417
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
3418
+ return ρσ_Result;
3419
+ })();
3420
+ }
3421
+ return ρσ_list_decorate([ (matched) ? new ExceptionGroup(self.message, matched) : null, (rest) ? new ExceptionGroup(self.message, rest) : null ]);
3422
+ };
3423
+ if (!ExceptionGroup.prototype.split.__argnames__) Object.defineProperties(ExceptionGroup.prototype.split, {
3424
+ __argnames__ : {value: ["condition"]},
3425
+ __module__ : {value: "__main__"}
3426
+ });
3427
+ ExceptionGroup.prototype.__repr__ = function __repr__() {
3428
+ var self = this;
3429
+ return ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add("ExceptionGroup(", repr(self.message)), ", "), repr(self.exceptions)), ")");
3430
+ };
3431
+ if (!ExceptionGroup.prototype.__repr__.__module__) Object.defineProperties(ExceptionGroup.prototype.__repr__, {
3432
+ __module__ : {value: "__main__"}
3433
+ });
3434
+ ExceptionGroup.prototype.__str__ = function __str__ () {
3435
+ if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
3436
+ return this.__repr__();
3437
+ };
3438
+ Object.defineProperty(ExceptionGroup.prototype, "__bases__", {value: [Exception]});
3439
+ ExceptionGroup.__name__ = "ExceptionGroup";
3440
+ ExceptionGroup.__qualname__ = "ExceptionGroup";
3441
+ ExceptionGroup.__module__ = "__main__";
3442
+ Object.defineProperty(ExceptionGroup.prototype, "__class__", {get: function() { return this.constructor; }, configurable: true});
3443
+ if (typeof Exception.__init_subclass__ === "function") Exception.__init_subclass__.call(ExceptionGroup);
3444
+ let ρσ_in, ρσ_desugar_kwargs, ρσ_exists, ρσ_JS_Proxy, ρσ_proxy_target_symbol, ρσ_attr_proxy_handler;
2380
3445
  function ρσ_eslice(arr, step, start, end) {
2381
3446
  var is_string;
2382
3447
  if (typeof arr === "string" || arr instanceof String) {
@@ -2505,15 +3570,59 @@ if (!ρσ_unpack_asarray.__argnames__) Object.defineProperties(ρσ_unpack_asarr
2505
3570
  __module__ : {value: "__main__"}
2506
3571
  });
2507
3572
 
3573
+ function ρσ_unpack_starred_asarray(iterable) {
3574
+ var ans, iterator, result;
3575
+ if (typeof iterable === "string" || iterable instanceof String) {
3576
+ return iterable.split("");
3577
+ }
3578
+ if (ρσ_arraylike(iterable)) {
3579
+ return iterable;
3580
+ }
3581
+ ans = [];
3582
+ if (typeof iterable[ρσ_iterator_symbol] === "function") {
3583
+ iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
3584
+ result = iterator.next();
3585
+ while (!result.done) {
3586
+ ans.push(result.value);
3587
+ result = iterator.next();
3588
+ }
3589
+ }
3590
+ return ans;
3591
+ };
3592
+ if (!ρσ_unpack_starred_asarray.__argnames__) Object.defineProperties(ρσ_unpack_starred_asarray, {
3593
+ __argnames__ : {value: ["iterable"]},
3594
+ __module__ : {value: "__main__"}
3595
+ });
3596
+
2508
3597
  function ρσ_extends(child, parent) {
2509
3598
  child.prototype = Object.create(parent.prototype);
2510
3599
  child.prototype.constructor = child;
3600
+ Object.setPrototypeOf(child, parent);
2511
3601
  };
2512
3602
  if (!ρσ_extends.__argnames__) Object.defineProperties(ρσ_extends, {
2513
3603
  __argnames__ : {value: ["child", "parent"]},
2514
3604
  __module__ : {value: "__main__"}
2515
3605
  });
2516
3606
 
3607
+ function ρσ_object_new(cls) {
3608
+ return Object.create(cls.prototype);
3609
+ };
3610
+ if (!ρσ_object_new.__argnames__) Object.defineProperties(ρσ_object_new, {
3611
+ __argnames__ : {value: ["cls"]},
3612
+ __module__ : {value: "__main__"}
3613
+ });
3614
+
3615
+ function ρσ_new(parent, cls) {
3616
+ if (parent && typeof parent.__new__ === "function") {
3617
+ return parent.__new__.apply(parent, Array.prototype.slice.call(arguments, 1));
3618
+ }
3619
+ return Object.create(cls.prototype);
3620
+ };
3621
+ if (!ρσ_new.__argnames__) Object.defineProperties(ρσ_new, {
3622
+ __argnames__ : {value: ["parent", "cls"]},
3623
+ __module__ : {value: "__main__"}
3624
+ });
3625
+
2517
3626
  ρσ_in = (function() {
2518
3627
  var ρσ_anonfunc = function () {
2519
3628
  if (typeof Map === "function" && typeof Set === "function") {
@@ -2592,11 +3701,16 @@ if (!ρσ_Iterable.__argnames__) Object.defineProperties(ρσ_Iterable, {
2592
3701
  if (typeof Object.assign === "function") {
2593
3702
  return (function() {
2594
3703
  var ρσ_anonfunc = function () {
2595
- var ans;
3704
+ var ans, arg;
2596
3705
  ans = Object.create(null);
2597
3706
  ans[ρσ_kwargs_symbol] = true;
2598
3707
  for (var i = 0; i < arguments.length; i++) {
2599
- Object.assign(ans, arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]);
3708
+ arg = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i];
3709
+ if (arg && arg.jsmap && typeof arg.jsmap.forEach === "function") {
3710
+ arg.jsmap.forEach(function(v, k) { ans[k] = v; });
3711
+ } else {
3712
+ Object.assign(ans, arg);
3713
+ }
2600
3714
  }
2601
3715
  return ans;
2602
3716
  };
@@ -2608,13 +3722,18 @@ if (!ρσ_Iterable.__argnames__) Object.defineProperties(ρσ_Iterable, {
2608
3722
  }
2609
3723
  return (function() {
2610
3724
  var ρσ_anonfunc = function () {
2611
- var ans, keys;
3725
+ var ans, arg, keys;
2612
3726
  ans = Object.create(null);
2613
3727
  ans[ρσ_kwargs_symbol] = true;
2614
3728
  for (var i = 0; i < arguments.length; i++) {
2615
- keys = Object.keys(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]);
2616
- for (var j = 0; j < keys.length; j++) {
2617
- ans[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], ans)] = (ρσ_expr_temp = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i])[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], ρσ_expr_temp)];
3729
+ arg = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i];
3730
+ if (arg && arg.jsmap && typeof arg.jsmap.forEach === "function") {
3731
+ arg.jsmap.forEach(function(v, k) { ans[k] = v; });
3732
+ } else {
3733
+ keys = Object.keys(arg);
3734
+ for (var j = 0; j < keys.length; j++) {
3735
+ ans[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], ans)] = arg[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], arg)];
3736
+ }
2618
3737
  }
2619
3738
  }
2620
3739
  return ans;
@@ -2638,7 +3757,7 @@ function ρσ_interpolate_kwargs(f, supplied_args) {
2638
3757
  has_prop = Object.prototype.hasOwnProperty;
2639
3758
  kwobj = supplied_args.pop();
2640
3759
  if (f.__handles_kwarg_interpolation__) {
2641
- args = new Array(Math.max(supplied_args.length, f.__argnames__.length) + 1);
3760
+ args = new Array(ρσ_list_add(Math.max(supplied_args.length, f.__argnames__.length), 1));
2642
3761
  args[args.length-1] = kwobj;
2643
3762
  for (var i = 0; i < args.length - 1; i++) {
2644
3763
  if (i < f.__argnames__.length) {
@@ -2682,11 +3801,17 @@ if (!ρσ_interpolate_kwargs_constructor.__argnames__) Object.defineProperties(
2682
3801
  });
2683
3802
 
2684
3803
  function ρσ_getitem(obj, key) {
3804
+ if (typeof obj === "function" && obj.__class_getitem__) {
3805
+ return obj.__class_getitem__(key);
3806
+ }
2685
3807
  if (obj.__getitem__) {
2686
3808
  return obj.__getitem__(key);
2687
3809
  }
3810
+ if (typeof ρσ_slice !== "undefined" && key instanceof ρσ_slice) {
3811
+ return ρσ_eslice(obj, (key.step !== null && key.step !== undefined) ? key.step : 1, (key.start !== null && key.start !== undefined) ? key.start : undefined, (key.stop !== null && key.stop !== undefined) ? key.stop : undefined);
3812
+ }
2688
3813
  if (typeof key === "number" && key < 0) {
2689
- key += obj.length;
3814
+ key = ρσ_list_iadd(key, obj.length);
2690
3815
  }
2691
3816
  return obj[(typeof key === "number" && key < 0) ? obj.length + key : key];
2692
3817
  };
@@ -2698,12 +3823,15 @@ if (!ρσ_getitem.__argnames__) Object.defineProperties(ρσ_getitem, {
2698
3823
  function ρσ_setitem(obj, key, val) {
2699
3824
  if (obj.__setitem__) {
2700
3825
  obj.__setitem__(key, val);
3826
+ } else if (typeof ρσ_slice !== "undefined" && key instanceof ρσ_slice) {
3827
+ ρσ_splice(obj, val, (key.start !== null && key.start !== undefined) ? key.start : 0, (key.stop !== null && key.stop !== undefined) ? key.stop : obj.length);
2701
3828
  } else {
2702
3829
  if (typeof key === "number" && key < 0) {
2703
- key += obj.length;
3830
+ key = ρσ_list_iadd(key, obj.length);
2704
3831
  }
2705
3832
  obj[(typeof key === "number" && key < 0) ? obj.length + key : key] = val;
2706
3833
  }
3834
+ return val;
2707
3835
  };
2708
3836
  if (!ρσ_setitem.__argnames__) Object.defineProperties(ρσ_setitem, {
2709
3837
  __argnames__ : {value: ["obj", "key", "val"]},
@@ -2713,11 +3841,13 @@ if (!ρσ_setitem.__argnames__) Object.defineProperties(ρσ_setitem, {
2713
3841
  function ρσ_delitem(obj, key) {
2714
3842
  if (obj.__delitem__) {
2715
3843
  obj.__delitem__(key);
3844
+ } else if (typeof ρσ_slice !== "undefined" && key instanceof ρσ_slice) {
3845
+ ρσ_delslice(obj, (key.step !== null && key.step !== undefined) ? key.step : 1, (key.start !== null && key.start !== undefined) ? key.start : undefined, (key.stop !== null && key.stop !== undefined) ? key.stop : undefined);
2716
3846
  } else if (typeof obj.splice === "function") {
2717
3847
  obj.splice(key, 1);
2718
3848
  } else {
2719
3849
  if (typeof key === "number" && key < 0) {
2720
- key += obj.length;
3850
+ key = ρσ_list_iadd(key, obj.length);
2721
3851
  }
2722
3852
  delete obj[key];
2723
3853
  }
@@ -2729,7 +3859,7 @@ if (!ρσ_delitem.__argnames__) Object.defineProperties(ρσ_delitem, {
2729
3859
 
2730
3860
  function ρσ_bound_index(idx, arr) {
2731
3861
  if (typeof idx === "number" && idx < 0) {
2732
- idx += arr.length;
3862
+ idx = ρσ_list_iadd(idx, arr.length);
2733
3863
  }
2734
3864
  return idx;
2735
3865
  };
@@ -2741,13 +3871,13 @@ if (!ρσ_bound_index.__argnames__) Object.defineProperties(ρσ_bound_index, {
2741
3871
  function ρσ_splice(arr, val, start, end) {
2742
3872
  start = start || 0;
2743
3873
  if (start < 0) {
2744
- start += arr.length;
3874
+ start = ρσ_list_iadd(start, arr.length);
2745
3875
  }
2746
3876
  if (end === undefined) {
2747
3877
  end = arr.length;
2748
3878
  }
2749
3879
  if (end < 0) {
2750
- end += arr.length;
3880
+ end = ρσ_list_iadd(end, arr.length);
2751
3881
  }
2752
3882
  Array.prototype.splice.apply(arr, [start, end - start].concat(val));
2753
3883
  };
@@ -2851,24 +3981,401 @@ function ρσ_mixin() {
2851
3981
  }
2852
3982
  p = Object.getPrototypeOf(p);
2853
3983
  }
2854
- for (var c = 1; c < arguments.length; c++) {
2855
- p = arguments[(typeof c === "number" && c < 0) ? arguments.length + c : c].prototype;
2856
- while (p && p !== Object.prototype) {
2857
- props = Object.getOwnPropertyNames(p);
2858
- for (var i = 0; i < props.length; i++) {
2859
- name = props[(typeof i === "number" && i < 0) ? props.length + i : i];
2860
- if (seen[(typeof name === "number" && name < 0) ? seen.length + name : name]) {
2861
- continue;
2862
- }
2863
- seen[(typeof name === "number" && name < 0) ? seen.length + name : name] = true;
2864
- resolved_props[(typeof name === "number" && name < 0) ? resolved_props.length + name : name] = Object.getOwnPropertyDescriptor(p, name);
2865
- }
2866
- p = Object.getPrototypeOf(p);
2867
- }
3984
+ for (var c = 1; c < arguments.length; c++) {
3985
+ p = arguments[(typeof c === "number" && c < 0) ? arguments.length + c : c].prototype;
3986
+ while (p && p !== Object.prototype) {
3987
+ props = Object.getOwnPropertyNames(p);
3988
+ for (var i = 0; i < props.length; i++) {
3989
+ name = props[(typeof i === "number" && i < 0) ? props.length + i : i];
3990
+ if (seen[(typeof name === "number" && name < 0) ? seen.length + name : name]) {
3991
+ continue;
3992
+ }
3993
+ seen[(typeof name === "number" && name < 0) ? seen.length + name : name] = true;
3994
+ resolved_props[(typeof name === "number" && name < 0) ? resolved_props.length + name : name] = Object.getOwnPropertyDescriptor(p, name);
3995
+ }
3996
+ p = Object.getPrototypeOf(p);
3997
+ }
3998
+ }
3999
+ Object.defineProperties(target, resolved_props);
4000
+ };
4001
+ if (!ρσ_mixin.__module__) Object.defineProperties(ρσ_mixin, {
4002
+ __module__ : {value: "__main__"}
4003
+ });
4004
+
4005
+ function ρσ_op_add(a, b) {
4006
+ if (a !== null && typeof a.__add__ === "function") {
4007
+ return a.__add__(b);
4008
+ }
4009
+ if (b !== null && typeof b.__radd__ === "function") {
4010
+ return b.__radd__(a);
4011
+ }
4012
+ return ρσ_list_add(a, b);
4013
+ };
4014
+ if (!ρσ_op_add.__argnames__) Object.defineProperties(ρσ_op_add, {
4015
+ __argnames__ : {value: ["a", "b"]},
4016
+ __module__ : {value: "__main__"}
4017
+ });
4018
+
4019
+ function ρσ_op_sub(a, b) {
4020
+ if (a !== null && typeof a.__sub__ === "function") {
4021
+ return a.__sub__(b);
4022
+ }
4023
+ if (b !== null && typeof b.__rsub__ === "function") {
4024
+ return b.__rsub__(a);
4025
+ }
4026
+ return a - b;
4027
+ };
4028
+ if (!ρσ_op_sub.__argnames__) Object.defineProperties(ρσ_op_sub, {
4029
+ __argnames__ : {value: ["a", "b"]},
4030
+ __module__ : {value: "__main__"}
4031
+ });
4032
+
4033
+ function ρσ_op_mul(a, b) {
4034
+ var result;
4035
+ if (a !== null && typeof a.__mul__ === "function") {
4036
+ return a.__mul__(b);
4037
+ }
4038
+ if (b !== null && typeof b.__rmul__ === "function") {
4039
+ return b.__rmul__(a);
4040
+ }
4041
+ if ((typeof a === "string" || a instanceof String) && typeof b === "number") {
4042
+ return a.repeat(b);
4043
+ }
4044
+ if ((typeof b === "string" || b instanceof String) && typeof a === "number") {
4045
+ return b.repeat(a);
4046
+ }
4047
+ if (Array.isArray(a) && typeof b === "number") {
4048
+ result = [];
4049
+ for (var ρσ_mi = 0; ρσ_mi < b; ρσ_mi++) {
4050
+ result = result.concat(a);
4051
+ }
4052
+ return ρσ_list_constructor(result);
4053
+ }
4054
+ if (Array.isArray(b) && typeof a === "number") {
4055
+ result = [];
4056
+ for (var ρσ_mi = 0; ρσ_mi < a; ρσ_mi++) {
4057
+ result = result.concat(b);
4058
+ }
4059
+ return ρσ_list_constructor(result);
4060
+ }
4061
+ return a * b;
4062
+ };
4063
+ if (!ρσ_op_mul.__argnames__) Object.defineProperties(ρσ_op_mul, {
4064
+ __argnames__ : {value: ["a", "b"]},
4065
+ __module__ : {value: "__main__"}
4066
+ });
4067
+
4068
+ function ρσ_op_truediv(a, b) {
4069
+ if (a !== null && typeof a.__truediv__ === "function") {
4070
+ return a.__truediv__(b);
4071
+ }
4072
+ if (b !== null && typeof b.__rtruediv__ === "function") {
4073
+ return b.__rtruediv__(a);
4074
+ }
4075
+ return a / b;
4076
+ };
4077
+ if (!ρσ_op_truediv.__argnames__) Object.defineProperties(ρσ_op_truediv, {
4078
+ __argnames__ : {value: ["a", "b"]},
4079
+ __module__ : {value: "__main__"}
4080
+ });
4081
+
4082
+ function ρσ_op_floordiv(a, b) {
4083
+ if (a !== null && typeof a.__floordiv__ === "function") {
4084
+ return a.__floordiv__(b);
4085
+ }
4086
+ if (b !== null && typeof b.__rfloordiv__ === "function") {
4087
+ return b.__rfloordiv__(a);
4088
+ }
4089
+ return Math.floor(a / b);
4090
+ };
4091
+ if (!ρσ_op_floordiv.__argnames__) Object.defineProperties(ρσ_op_floordiv, {
4092
+ __argnames__ : {value: ["a", "b"]},
4093
+ __module__ : {value: "__main__"}
4094
+ });
4095
+
4096
+ function ρσ_op_mod(a, b) {
4097
+ if (a !== null && typeof a.__mod__ === "function") {
4098
+ return a.__mod__(b);
4099
+ }
4100
+ if (b !== null && typeof b.__rmod__ === "function") {
4101
+ return b.__rmod__(a);
4102
+ }
4103
+ return a % b;
4104
+ };
4105
+ if (!ρσ_op_mod.__argnames__) Object.defineProperties(ρσ_op_mod, {
4106
+ __argnames__ : {value: ["a", "b"]},
4107
+ __module__ : {value: "__main__"}
4108
+ });
4109
+
4110
+ function ρσ_op_pow(a, b) {
4111
+ if (a !== null && typeof a.__pow__ === "function") {
4112
+ return a.__pow__(b);
4113
+ }
4114
+ if (b !== null && typeof b.__rpow__ === "function") {
4115
+ return b.__rpow__(a);
4116
+ }
4117
+ return Math.pow(a, b);
4118
+ };
4119
+ if (!ρσ_op_pow.__argnames__) Object.defineProperties(ρσ_op_pow, {
4120
+ __argnames__ : {value: ["a", "b"]},
4121
+ __module__ : {value: "__main__"}
4122
+ });
4123
+
4124
+ function ρσ_op_and(a, b) {
4125
+ if (a !== null && typeof a.__and__ === "function") {
4126
+ return a.__and__(b);
4127
+ }
4128
+ if (b !== null && typeof b.__rand__ === "function") {
4129
+ return b.__rand__(a);
4130
+ }
4131
+ return a & b;
4132
+ };
4133
+ if (!ρσ_op_and.__argnames__) Object.defineProperties(ρσ_op_and, {
4134
+ __argnames__ : {value: ["a", "b"]},
4135
+ __module__ : {value: "__main__"}
4136
+ });
4137
+
4138
+ function ρσ_op_or(a, b) {
4139
+ if (a !== null && typeof a.__or__ === "function") {
4140
+ return a.__or__(b);
4141
+ }
4142
+ if (b !== null && typeof b.__ror__ === "function") {
4143
+ return b.__ror__(a);
4144
+ }
4145
+ return a | b;
4146
+ };
4147
+ if (!ρσ_op_or.__argnames__) Object.defineProperties(ρσ_op_or, {
4148
+ __argnames__ : {value: ["a", "b"]},
4149
+ __module__ : {value: "__main__"}
4150
+ });
4151
+
4152
+ function ρσ_op_xor(a, b) {
4153
+ if (a !== null && typeof a.__xor__ === "function") {
4154
+ return a.__xor__(b);
4155
+ }
4156
+ if (b !== null && typeof b.__rxor__ === "function") {
4157
+ return b.__rxor__(a);
4158
+ }
4159
+ return a ^ b;
4160
+ };
4161
+ if (!ρσ_op_xor.__argnames__) Object.defineProperties(ρσ_op_xor, {
4162
+ __argnames__ : {value: ["a", "b"]},
4163
+ __module__ : {value: "__main__"}
4164
+ });
4165
+
4166
+ function ρσ_op_lshift(a, b) {
4167
+ if (a !== null && typeof a.__lshift__ === "function") {
4168
+ return a.__lshift__(b);
4169
+ }
4170
+ if (b !== null && typeof b.__rlshift__ === "function") {
4171
+ return b.__rlshift__(a);
4172
+ }
4173
+ return a << b;
4174
+ };
4175
+ if (!ρσ_op_lshift.__argnames__) Object.defineProperties(ρσ_op_lshift, {
4176
+ __argnames__ : {value: ["a", "b"]},
4177
+ __module__ : {value: "__main__"}
4178
+ });
4179
+
4180
+ function ρσ_op_rshift(a, b) {
4181
+ if (a !== null && typeof a.__rshift__ === "function") {
4182
+ return a.__rshift__(b);
4183
+ }
4184
+ if (b !== null && typeof b.__rrshift__ === "function") {
4185
+ return b.__rrshift__(a);
4186
+ }
4187
+ return a >> b;
4188
+ };
4189
+ if (!ρσ_op_rshift.__argnames__) Object.defineProperties(ρσ_op_rshift, {
4190
+ __argnames__ : {value: ["a", "b"]},
4191
+ __module__ : {value: "__main__"}
4192
+ });
4193
+
4194
+ function ρσ_list_add(a, b) {
4195
+ if (Array.isArray(a) && Array.isArray(b)) {
4196
+ return ρσ_list_constructor(a.concat(b));
4197
+ }
4198
+ return a + b;
4199
+ };
4200
+ if (!ρσ_list_add.__argnames__) Object.defineProperties(ρσ_list_add, {
4201
+ __argnames__ : {value: ["a", "b"]},
4202
+ __module__ : {value: "__main__"}
4203
+ });
4204
+
4205
+ function ρσ_list_iadd(a, b) {
4206
+ if (Array.isArray(a) && Array.isArray(b)) {
4207
+ Array.prototype.push.apply(a, b);
4208
+ return a;
4209
+ }
4210
+ return a + b;
4211
+ };
4212
+ if (!ρσ_list_iadd.__argnames__) Object.defineProperties(ρσ_list_iadd, {
4213
+ __argnames__ : {value: ["a", "b"]},
4214
+ __module__ : {value: "__main__"}
4215
+ });
4216
+
4217
+ function ρσ_op_neg(a) {
4218
+ if (a !== null && typeof a.__neg__ === "function") {
4219
+ return a.__neg__();
4220
+ }
4221
+ return -a;
4222
+ };
4223
+ if (!ρσ_op_neg.__argnames__) Object.defineProperties(ρσ_op_neg, {
4224
+ __argnames__ : {value: ["a"]},
4225
+ __module__ : {value: "__main__"}
4226
+ });
4227
+
4228
+ function ρσ_op_pos(a) {
4229
+ if (a !== null && typeof a.__pos__ === "function") {
4230
+ return a.__pos__();
2868
4231
  }
2869
- Object.defineProperties(target, resolved_props);
4232
+ return +a;
2870
4233
  };
2871
- if (!ρσ_mixin.__module__) Object.defineProperties(ρσ_mixin, {
4234
+ if (!ρσ_op_pos.__argnames__) Object.defineProperties(ρσ_op_pos, {
4235
+ __argnames__ : {value: ["a"]},
4236
+ __module__ : {value: "__main__"}
4237
+ });
4238
+
4239
+ function ρσ_op_invert(a) {
4240
+ if (a !== null && typeof a.__invert__ === "function") {
4241
+ return a.__invert__();
4242
+ }
4243
+ return ~a;
4244
+ };
4245
+ if (!ρσ_op_invert.__argnames__) Object.defineProperties(ρσ_op_invert, {
4246
+ __argnames__ : {value: ["a"]},
4247
+ __module__ : {value: "__main__"}
4248
+ });
4249
+
4250
+ function ρσ_op_iadd(a, b) {
4251
+ if (a !== null && typeof a.__iadd__ === "function") {
4252
+ return a.__iadd__(b);
4253
+ }
4254
+ return ρσ_op_add(a, b);
4255
+ };
4256
+ if (!ρσ_op_iadd.__argnames__) Object.defineProperties(ρσ_op_iadd, {
4257
+ __argnames__ : {value: ["a", "b"]},
4258
+ __module__ : {value: "__main__"}
4259
+ });
4260
+
4261
+ function ρσ_op_isub(a, b) {
4262
+ if (a !== null && typeof a.__isub__ === "function") {
4263
+ return a.__isub__(b);
4264
+ }
4265
+ return ρσ_op_sub(a, b);
4266
+ };
4267
+ if (!ρσ_op_isub.__argnames__) Object.defineProperties(ρσ_op_isub, {
4268
+ __argnames__ : {value: ["a", "b"]},
4269
+ __module__ : {value: "__main__"}
4270
+ });
4271
+
4272
+ function ρσ_op_imul(a, b) {
4273
+ if (a !== null && typeof a.__imul__ === "function") {
4274
+ return a.__imul__(b);
4275
+ }
4276
+ return ρσ_op_mul(a, b);
4277
+ };
4278
+ if (!ρσ_op_imul.__argnames__) Object.defineProperties(ρσ_op_imul, {
4279
+ __argnames__ : {value: ["a", "b"]},
4280
+ __module__ : {value: "__main__"}
4281
+ });
4282
+
4283
+ function ρσ_op_itruediv(a, b) {
4284
+ if (a !== null && typeof a.__itruediv__ === "function") {
4285
+ return a.__itruediv__(b);
4286
+ }
4287
+ return ρσ_op_truediv(a, b);
4288
+ };
4289
+ if (!ρσ_op_itruediv.__argnames__) Object.defineProperties(ρσ_op_itruediv, {
4290
+ __argnames__ : {value: ["a", "b"]},
4291
+ __module__ : {value: "__main__"}
4292
+ });
4293
+
4294
+ function ρσ_op_ifloordiv(a, b) {
4295
+ if (a !== null && typeof a.__ifloordiv__ === "function") {
4296
+ return a.__ifloordiv__(b);
4297
+ }
4298
+ return ρσ_op_floordiv(a, b);
4299
+ };
4300
+ if (!ρσ_op_ifloordiv.__argnames__) Object.defineProperties(ρσ_op_ifloordiv, {
4301
+ __argnames__ : {value: ["a", "b"]},
4302
+ __module__ : {value: "__main__"}
4303
+ });
4304
+
4305
+ function ρσ_op_imod(a, b) {
4306
+ if (a !== null && typeof a.__imod__ === "function") {
4307
+ return a.__imod__(b);
4308
+ }
4309
+ return ρσ_op_mod(a, b);
4310
+ };
4311
+ if (!ρσ_op_imod.__argnames__) Object.defineProperties(ρσ_op_imod, {
4312
+ __argnames__ : {value: ["a", "b"]},
4313
+ __module__ : {value: "__main__"}
4314
+ });
4315
+
4316
+ function ρσ_op_ipow(a, b) {
4317
+ if (a !== null && typeof a.__ipow__ === "function") {
4318
+ return a.__ipow__(b);
4319
+ }
4320
+ return ρσ_op_pow(a, b);
4321
+ };
4322
+ if (!ρσ_op_ipow.__argnames__) Object.defineProperties(ρσ_op_ipow, {
4323
+ __argnames__ : {value: ["a", "b"]},
4324
+ __module__ : {value: "__main__"}
4325
+ });
4326
+
4327
+ function ρσ_op_iand(a, b) {
4328
+ if (a !== null && typeof a.__iand__ === "function") {
4329
+ return a.__iand__(b);
4330
+ }
4331
+ return ρσ_op_and(a, b);
4332
+ };
4333
+ if (!ρσ_op_iand.__argnames__) Object.defineProperties(ρσ_op_iand, {
4334
+ __argnames__ : {value: ["a", "b"]},
4335
+ __module__ : {value: "__main__"}
4336
+ });
4337
+
4338
+ function ρσ_op_ior(a, b) {
4339
+ if (a !== null && typeof a.__ior__ === "function") {
4340
+ return a.__ior__(b);
4341
+ }
4342
+ return ρσ_op_or(a, b);
4343
+ };
4344
+ if (!ρσ_op_ior.__argnames__) Object.defineProperties(ρσ_op_ior, {
4345
+ __argnames__ : {value: ["a", "b"]},
4346
+ __module__ : {value: "__main__"}
4347
+ });
4348
+
4349
+ function ρσ_op_ixor(a, b) {
4350
+ if (a !== null && typeof a.__ixor__ === "function") {
4351
+ return a.__ixor__(b);
4352
+ }
4353
+ return ρσ_op_xor(a, b);
4354
+ };
4355
+ if (!ρσ_op_ixor.__argnames__) Object.defineProperties(ρσ_op_ixor, {
4356
+ __argnames__ : {value: ["a", "b"]},
4357
+ __module__ : {value: "__main__"}
4358
+ });
4359
+
4360
+ function ρσ_op_ilshift(a, b) {
4361
+ if (a !== null && typeof a.__ilshift__ === "function") {
4362
+ return a.__ilshift__(b);
4363
+ }
4364
+ return ρσ_op_lshift(a, b);
4365
+ };
4366
+ if (!ρσ_op_ilshift.__argnames__) Object.defineProperties(ρσ_op_ilshift, {
4367
+ __argnames__ : {value: ["a", "b"]},
4368
+ __module__ : {value: "__main__"}
4369
+ });
4370
+
4371
+ function ρσ_op_irshift(a, b) {
4372
+ if (a !== null && typeof a.__irshift__ === "function") {
4373
+ return a.__irshift__(b);
4374
+ }
4375
+ return ρσ_op_rshift(a, b);
4376
+ };
4377
+ if (!ρσ_op_irshift.__argnames__) Object.defineProperties(ρσ_op_irshift, {
4378
+ __argnames__ : {value: ["a", "b"]},
2872
4379
  __module__ : {value: "__main__"}
2873
4380
  });
2874
4381
 
@@ -2917,12 +4424,121 @@ function ρσ_instanceof() {
2917
4424
  if (!ρσ_instanceof.__module__) Object.defineProperties(ρσ_instanceof, {
2918
4425
  __module__ : {value: "__main__"}
2919
4426
  });
4427
+
4428
+ ρσ_JS_Proxy = typeof Proxy === "function" ? Proxy : null;
4429
+ ρσ_proxy_target_symbol = typeof Symbol === "function" ? Symbol("ρσ_proxy_target") : "__ρσ_proxy_target__";
4430
+ ρσ_attr_proxy_handler = (function(){
4431
+ var ρσ_d = {};
4432
+ ρσ_d["get"] = (function() {
4433
+ var ρσ_anonfunc = function (target, prop, receiver) {
4434
+ var val;
4435
+ if (prop === ρσ_proxy_target_symbol) {
4436
+ return target;
4437
+ }
4438
+ if (typeof prop === "symbol") {
4439
+ return Reflect.get(target, prop, receiver);
4440
+ }
4441
+ if (typeof target.__getattribute__ === "function" && prop !== "__getattribute__") {
4442
+ try {
4443
+ return target.__getattribute__.call(receiver, prop);
4444
+ } catch (ρσ_Exception) {
4445
+ ρσ_last_exception = ρσ_Exception;
4446
+ if (ρσ_Exception instanceof AttributeError) {
4447
+ if (typeof target.__getattr__ === "function") {
4448
+ return target.__getattr__.call(receiver, prop);
4449
+ }
4450
+ throw ρσ_Exception;
4451
+ } else {
4452
+ throw ρσ_Exception;
4453
+ }
4454
+ }
4455
+ }
4456
+ val = Reflect.get(target, prop, receiver);
4457
+ if (val === undefined && typeof target.__getattr__ === "function" && !(prop in target)) {
4458
+ return target.__getattr__.call(receiver, prop);
4459
+ }
4460
+ return val;
4461
+ };
4462
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
4463
+ __argnames__ : {value: ["target", "prop", "receiver"]},
4464
+ __module__ : {value: "__main__"}
4465
+ });
4466
+ return ρσ_anonfunc;
4467
+ })();
4468
+ ρσ_d["set"] = (function() {
4469
+ var ρσ_anonfunc = function (target, prop, value, receiver) {
4470
+ if (typeof target.__setattr__ === "function") {
4471
+ target.__setattr__.call(receiver, prop, value);
4472
+ return true;
4473
+ }
4474
+ return Reflect.set(target, prop, value, target);
4475
+ };
4476
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
4477
+ __argnames__ : {value: ["target", "prop", "value", "receiver"]},
4478
+ __module__ : {value: "__main__"}
4479
+ });
4480
+ return ρσ_anonfunc;
4481
+ })();
4482
+ ρσ_d["deleteProperty"] = (function() {
4483
+ var ρσ_anonfunc = function (target, prop) {
4484
+ if (typeof target.__delattr__ === "function") {
4485
+ target.__delattr__.call(target, prop);
4486
+ return true;
4487
+ }
4488
+ return Reflect.deleteProperty(target, prop);
4489
+ };
4490
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
4491
+ __argnames__ : {value: ["target", "prop"]},
4492
+ __module__ : {value: "__main__"}
4493
+ });
4494
+ return ρσ_anonfunc;
4495
+ })();
4496
+ return ρσ_d;
4497
+ }).call(this);
4498
+ function ρσ_object_setattr(obj, name, value) {
4499
+ var target;
4500
+ target = obj[ρσ_proxy_target_symbol];
4501
+ if (target === undefined) {
4502
+ target = obj;
4503
+ }
4504
+ target[name] = value;
4505
+ };
4506
+ if (!ρσ_object_setattr.__argnames__) Object.defineProperties(ρσ_object_setattr, {
4507
+ __argnames__ : {value: ["obj", "name", "value"]},
4508
+ __module__ : {value: "__main__"}
4509
+ });
4510
+
4511
+ function ρσ_object_getattr(obj, name) {
4512
+ var target;
4513
+ target = obj[ρσ_proxy_target_symbol];
4514
+ if (target === undefined) {
4515
+ target = obj;
4516
+ }
4517
+ return target[(typeof name === "number" && name < 0) ? target.length + name : name];
4518
+ };
4519
+ if (!ρσ_object_getattr.__argnames__) Object.defineProperties(ρσ_object_getattr, {
4520
+ __argnames__ : {value: ["obj", "name"]},
4521
+ __module__ : {value: "__main__"}
4522
+ });
4523
+
4524
+ function ρσ_object_delattr(obj, name) {
4525
+ var target;
4526
+ target = obj[ρσ_proxy_target_symbol];
4527
+ if (target === undefined) {
4528
+ target = obj;
4529
+ }
4530
+ delete target[name];
4531
+ };
4532
+ if (!ρσ_object_delattr.__argnames__) Object.defineProperties(ρσ_object_delattr, {
4533
+ __argnames__ : {value: ["obj", "name"]},
4534
+ __module__ : {value: "__main__"}
4535
+ });
2920
4536
  function sum(iterable, start) {
2921
4537
  var ans, iterator, r;
2922
4538
  if (Array.isArray(iterable)) {
2923
4539
  return iterable.reduce((function() {
2924
4540
  var ρσ_anonfunc = function (prev, cur) {
2925
- return prev + cur;
4541
+ return ρσ_list_add(prev, cur);
2926
4542
  };
2927
4543
  if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
2928
4544
  __argnames__ : {value: ["prev", "cur"]},
@@ -2935,7 +4551,7 @@ function sum(iterable, start) {
2935
4551
  iterator = iter(iterable);
2936
4552
  r = iterator.next();
2937
4553
  while (!r.done) {
2938
- ans += r.value;
4554
+ ans = ρσ_list_iadd(ans, r.value);
2939
4555
  r = iterator.next();
2940
4556
  }
2941
4557
  return ans;
@@ -3064,13 +4680,22 @@ if (!zip.__module__) Object.defineProperties(zip, {
3064
4680
  });
3065
4681
 
3066
4682
  function any(iterable) {
3067
- var i;
3068
- var ρσ_Iter0 = ρσ_Iterable(iterable);
3069
- for (var ρσ_Index0 = 0; ρσ_Index0 < ρσ_Iter0.length; ρσ_Index0++) {
3070
- i = ρσ_Iter0[ρσ_Index0];
3071
- if (i) {
4683
+ var iterator, r;
4684
+ if (Array.isArray(iterable) || typeof iterable === "string") {
4685
+ for (var i = 0; i < iterable.length; i++) {
4686
+ if (iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i]) {
4687
+ return true;
4688
+ }
4689
+ }
4690
+ return false;
4691
+ }
4692
+ iterator = iter(iterable);
4693
+ r = iterator.next();
4694
+ while (!r.done) {
4695
+ if (r.value) {
3072
4696
  return true;
3073
4697
  }
4698
+ r = iterator.next();
3074
4699
  }
3075
4700
  return false;
3076
4701
  };
@@ -3080,13 +4705,22 @@ if (!any.__argnames__) Object.defineProperties(any, {
3080
4705
  });
3081
4706
 
3082
4707
  function all(iterable) {
3083
- var i;
3084
- var ρσ_Iter1 = ρσ_Iterable(iterable);
3085
- for (var ρσ_Index1 = 0; ρσ_Index1 < ρσ_Iter1.length; ρσ_Index1++) {
3086
- i = ρσ_Iter1[ρσ_Index1];
3087
- if (!i) {
4708
+ var iterator, r;
4709
+ if (Array.isArray(iterable) || typeof iterable === "string") {
4710
+ for (var i = 0; i < iterable.length; i++) {
4711
+ if (!iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i]) {
4712
+ return false;
4713
+ }
4714
+ }
4715
+ return true;
4716
+ }
4717
+ iterator = iter(iterable);
4718
+ r = iterator.next();
4719
+ while (!r.done) {
4720
+ if (!r.value) {
3088
4721
  return false;
3089
4722
  }
4723
+ r = iterator.next();
3090
4724
  }
3091
4725
  return true;
3092
4726
  };
@@ -3094,7 +4728,7 @@ if (!all.__argnames__) Object.defineProperties(all, {
3094
4728
  __argnames__ : {value: ["iterable"]},
3095
4729
  __module__ : {value: "__main__"}
3096
4730
  });
3097
- var decimal_sep, define_str_func, ρσ_unpack, ρσ_orig_split, ρσ_orig_replace;
4731
+ let decimal_sep, define_str_func, ρσ_unpack, ρσ_orig_split, ρσ_orig_replace;
3098
4732
  decimal_sep = 1.1.toLocaleString()[1];
3099
4733
  function ρσ_repr_js_builtin(x, as_array) {
3100
4734
  var ans, b, keys, key;
@@ -3109,10 +4743,10 @@ function ρσ_repr_js_builtin(x, as_array) {
3109
4743
  keys = Object.keys(x);
3110
4744
  for (var k = 0; k < keys.length; k++) {
3111
4745
  key = keys[(typeof k === "number" && k < 0) ? keys.length + k : k];
3112
- ans.push(JSON.stringify(key) + ":" + ρσ_repr(x[(typeof key === "number" && key < 0) ? x.length + key : key]));
4746
+ ans.push(ρσ_list_add(ρσ_list_add(JSON.stringify(key), ":"), ρσ_repr(x[(typeof key === "number" && key < 0) ? x.length + key : key])));
3113
4747
  }
3114
4748
  }
3115
- return b[0] + ans.join(", ") + b[1];
4749
+ return ρσ_list_add(ρσ_list_add(b[0], ans.join(", ")), b[1]);
3116
4750
  };
3117
4751
  if (!ρσ_repr_js_builtin.__argnames__) Object.defineProperties(ρσ_repr_js_builtin, {
3118
4752
  __argnames__ : {value: ["x", "as_array"]},
@@ -3128,14 +4762,14 @@ function ρσ_html_element_to_string(elem) {
3128
4762
  if (attr.specified) {
3129
4763
  val = attr.value;
3130
4764
  if (val.length > 10) {
3131
- val = val.slice(0, 15) + "...";
4765
+ val = ρσ_list_add(val.slice(0, 15), "...");
3132
4766
  }
3133
4767
  val = JSON.stringify(val);
3134
- attrs.push("" + ρσ_str.format("{}", attr.name) + "=" + ρσ_str.format("{}", val) + "");
4768
+ attrs.push(ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add("", ρσ_str.format("{}", attr.name)), "="), ρσ_str.format("{}", val)), ""));
3135
4769
  }
3136
4770
  }
3137
- attrs = (attrs.length) ? " " + attrs.join(" ") : "";
3138
- ans = "<" + ρσ_str.format("{}", elem.tagName) + "" + ρσ_str.format("{}", attrs) + ">";
4771
+ attrs = (attrs.length) ? ρσ_list_add(" ", attrs.join(" ")) : "";
4772
+ ans = ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add("<", ρσ_str.format("{}", elem.tagName)), ""), ρσ_str.format("{}", attrs)), ">");
3139
4773
  return ans;
3140
4774
  };
3141
4775
  if (!ρσ_html_element_to_string.__argnames__) Object.defineProperties(ρσ_html_element_to_string, {
@@ -3165,7 +4799,7 @@ function ρσ_repr(x) {
3165
4799
  } else {
3166
4800
  name = Object.prototype.toString.call(x).slice(8, -1);
3167
4801
  if (ρσ_not_equals("Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".indexOf(name), -1)) {
3168
- return name + "([" + x.map((function() {
4802
+ return ρσ_list_add(ρσ_list_add(ρσ_list_add(name, "(["), x.map((function() {
3169
4803
  var ρσ_anonfunc = function (i) {
3170
4804
  return str.format("0x{:02x}", i);
3171
4805
  };
@@ -3174,7 +4808,7 @@ function ρσ_repr(x) {
3174
4808
  __module__ : {value: "__main__"}
3175
4809
  });
3176
4810
  return ρσ_anonfunc;
3177
- })()).join(", ") + "])";
4811
+ })()).join(", ")), "])");
3178
4812
  }
3179
4813
  if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) {
3180
4814
  ans = ρσ_html_element_to_string(x);
@@ -3192,7 +4826,7 @@ function ρσ_repr(x) {
3192
4826
  }
3193
4827
  }
3194
4828
  }
3195
- return ans + "";
4829
+ return ρσ_list_add(ans, "");
3196
4830
  };
3197
4831
  if (!ρσ_repr.__argnames__) Object.defineProperties(ρσ_repr, {
3198
4832
  __argnames__ : {value: ["x"]},
@@ -3219,7 +4853,7 @@ function ρσ_str(x) {
3219
4853
  } else if (typeof x.toString === "function") {
3220
4854
  name = Object.prototype.toString.call(x).slice(8, -1);
3221
4855
  if (ρσ_not_equals("Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".indexOf(name), -1)) {
3222
- return name + "([" + x.map((function() {
4856
+ return ρσ_list_add(ρσ_list_add(ρσ_list_add(name, "(["), x.map((function() {
3223
4857
  var ρσ_anonfunc = function (i) {
3224
4858
  return str.format("0x{:02x}", i);
3225
4859
  };
@@ -3228,7 +4862,7 @@ function ρσ_str(x) {
3228
4862
  __module__ : {value: "__main__"}
3229
4863
  });
3230
4864
  return ρσ_anonfunc;
3231
- })()).join(", ") + "])";
4865
+ })()).join(", ")), "])");
3232
4866
  }
3233
4867
  if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) {
3234
4868
  ans = ρσ_html_element_to_string(x);
@@ -3241,7 +4875,7 @@ function ρσ_str(x) {
3241
4875
  } else if (typeof x === "object" && !x.toString) {
3242
4876
  ans = ρσ_repr_js_builtin(x);
3243
4877
  }
3244
- return ans + "";
4878
+ return ρσ_list_add(ans, "");
3245
4879
  };
3246
4880
  if (!ρσ_str.__argnames__) Object.defineProperties(ρσ_str, {
3247
4881
  __argnames__ : {value: ["x"]},
@@ -3319,7 +4953,7 @@ define_str_func("format", (function() {
3319
4953
  if (!Object.prototype.hasOwnProperty.call(kwargs, key)) {
3320
4954
  return "";
3321
4955
  }
3322
- return "" + kwargs[(typeof key === "number" && key < 0) ? kwargs.length + key : key];
4956
+ return ρσ_list_add("", kwargs[(typeof key === "number" && key < 0) ? kwargs.length + key : key]);
3323
4957
  };
3324
4958
  if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
3325
4959
  __argnames__ : {value: ["match", "key"]},
@@ -3436,12 +5070,12 @@ define_str_func("format", (function() {
3436
5070
  if (ftype === "b") {
3437
5071
  value = (value >>> 0).toString(2);
3438
5072
  if (fhash) {
3439
- value = "0b" + value;
5073
+ value = ρσ_list_add("0b", value);
3440
5074
  }
3441
5075
  } else if (ftype === "c") {
3442
5076
  if (value > 65535) {
3443
5077
  code = value - 65536;
3444
- value = String.fromCharCode(55296 + (code >> 10), 56320 + (code & 1023));
5078
+ value = String.fromCharCode(ρσ_list_add(55296, (code >> 10)), ρσ_list_add(56320, (code & 1023)));
3445
5079
  } else {
3446
5080
  value = String.fromCharCode(value);
3447
5081
  }
@@ -3454,13 +5088,13 @@ define_str_func("format", (function() {
3454
5088
  } else if (ftype === "o") {
3455
5089
  value = value.toString(8);
3456
5090
  if (fhash) {
3457
- value = "0o" + value;
5091
+ value = ρσ_list_add("0o", value);
3458
5092
  }
3459
5093
  } else if (lftype === "x") {
3460
5094
  value = value.toString(16);
3461
5095
  value = (ftype === "x") ? value.toLowerCase() : value.toUpperCase();
3462
5096
  if (fhash) {
3463
- value = "0x" + value;
5097
+ value = ρσ_list_add("0x", value);
3464
5098
  }
3465
5099
  }
3466
5100
  }
@@ -3476,7 +5110,7 @@ define_str_func("format", (function() {
3476
5110
  value = (ftype === "F") ? value.toUpperCase() : value.toLowerCase();
3477
5111
  } else if (lftype === "%") {
3478
5112
  value *= 100;
3479
- value = safe_fixed(value, prec, comma) + "%";
5113
+ value = ρσ_list_add(safe_fixed(value, prec, comma), "%");
3480
5114
  } else if (lftype === "g") {
3481
5115
  prec = max(1, prec);
3482
5116
  exp = parseInt(split(value.toExponential(prec - 1).toLowerCase(), "e")[1], 10);
@@ -3501,17 +5135,17 @@ define_str_func("format", (function() {
3501
5135
  }
3502
5136
  value = safe_comma(value, comma);
3503
5137
  }
3504
- value += "";
5138
+ value = ρσ_list_iadd(value, "");
3505
5139
  if (!isNaN(precision)) {
3506
5140
  value = value.slice(0, precision);
3507
5141
  }
3508
5142
  }
3509
- value += "";
5143
+ value = ρσ_list_iadd(value, "");
3510
5144
  if (is_numeric && sign) {
3511
5145
  nval = Number(value);
3512
5146
  is_positive = !isNaN(nval) && nval >= 0;
3513
5147
  if (is_positive && (sign === " " || sign === "+")) {
3514
- value = sign + value;
5148
+ value = ρσ_list_add(sign, value);
3515
5149
  }
3516
5150
  }
3517
5151
  function repeat(char, num) {
@@ -3530,25 +5164,25 @@ define_str_func("format", (function() {
3530
5164
  }
3531
5165
  width = parseInt(width || "-1", 10);
3532
5166
  if (isNaN(width)) {
3533
- throw new ValueError("Invalid width specification: " + width);
5167
+ throw new ValueError(ρσ_list_add("Invalid width specification: ", width));
3534
5168
  }
3535
5169
  if (fill && value.length < width) {
3536
5170
  if (align === "<") {
3537
- value = value + repeat(fill, width - value.length);
5171
+ value = ρσ_list_add(value, repeat(fill, width - value.length));
3538
5172
  } else if (align === ">") {
3539
- value = repeat(fill, width - value.length) + value;
5173
+ value = ρσ_list_add(repeat(fill, width - value.length), value);
3540
5174
  } else if (align === "^") {
3541
5175
  left = Math.floor((width - value.length) / 2);
3542
5176
  right = width - left - value.length;
3543
- value = repeat(fill, left) + value + repeat(fill, right);
5177
+ value = ρσ_list_add(ρσ_list_add(repeat(fill, left), value), repeat(fill, right));
3544
5178
  } else if (align === "=") {
3545
5179
  if (ρσ_in(value[0], "+- ")) {
3546
- value = value[0] + repeat(fill, width - value.length) + value.slice(1);
5180
+ value = ρσ_list_add(ρσ_list_add(value[0], repeat(fill, width - value.length)), value.slice(1));
3547
5181
  } else {
3548
- value = repeat(fill, width - value.length) + value;
5182
+ value = ρσ_list_add(repeat(fill, width - value.length), value);
3549
5183
  }
3550
5184
  } else {
3551
- throw new ValueError("Unrecognized alignment: " + align);
5185
+ throw new ValueError(ρσ_list_add("Unrecognized alignment: ", align));
3552
5186
  }
3553
5187
  }
3554
5188
  return value;
@@ -3571,18 +5205,18 @@ define_str_func("format", (function() {
3571
5205
  } else if (ch === ":") {
3572
5206
  state = 2;
3573
5207
  } else {
3574
- key += ch;
5208
+ key = ρσ_list_iadd(key, ch);
3575
5209
  }
3576
5210
  } else if (state === 1) {
3577
5211
  if (ch === ":") {
3578
5212
  state = 2;
3579
5213
  } else {
3580
- transformer += ch;
5214
+ transformer = ρσ_list_iadd(transformer, ch);
3581
5215
  }
3582
5216
  } else {
3583
- format_spec += ch;
5217
+ format_spec = ρσ_list_iadd(format_spec, ch);
3584
5218
  }
3585
- pos += 1;
5219
+ pos = ρσ_list_iadd(pos, 1);
3586
5220
  }
3587
5221
  return [key, transformer, format_spec];
3588
5222
  };
@@ -3599,7 +5233,7 @@ define_str_func("format", (function() {
3599
5233
  transformer = ρσ_unpack[1];
3600
5234
  format_spec = ρσ_unpack[2];
3601
5235
  if (transformer && ['a', 'r', 's'].indexOf(transformer) === -1) {
3602
- throw new ValueError("Unknown conversion specifier: " + transformer);
5236
+ throw new ValueError(ρσ_list_add("Unknown conversion specifier: ", transformer));
3603
5237
  }
3604
5238
  ends_with_equal = key.endsWith("=");
3605
5239
  if (ends_with_equal) {
@@ -3626,20 +5260,20 @@ define_str_func("format", (function() {
3626
5260
  throw new ValueError("cannot switch from manual field specification to automatic field numbering");
3627
5261
  }
3628
5262
  if (idx >= args.length) {
3629
- throw new IndexError("Not enough arguments to match template: " + template);
5263
+ throw new IndexError(ρσ_list_add("Not enough arguments to match template: ", template));
3630
5264
  }
3631
5265
  object = args[(typeof idx === "number" && idx < 0) ? args.length + idx : idx];
3632
- idx += 1;
5266
+ idx = ρσ_list_iadd(idx, 1);
3633
5267
  }
3634
5268
  if (typeof object === "function") {
3635
5269
  object = object();
3636
5270
  }
3637
- ans = "" + object;
5271
+ ans = ρσ_list_add("", object);
3638
5272
  if (format_spec) {
3639
5273
  ans = apply_formatting(ans, format_spec);
3640
5274
  }
3641
5275
  if (ends_with_equal) {
3642
- ans = "" + ρσ_str.format("{}", key) + "=" + ρσ_str.format("{}", ans) + "";
5276
+ ans = ρσ_list_add(ρσ_list_add(ρσ_list_add(ρσ_list_add("", ρσ_str.format("{}", key)), "="), ρσ_str.format("{}", ans)), "");
3643
5277
  }
3644
5278
  return ans;
3645
5279
  };
@@ -3656,35 +5290,35 @@ define_str_func("format", (function() {
3656
5290
  ch = template[(typeof pos === "number" && pos < 0) ? template.length + pos : pos];
3657
5291
  if (in_brace) {
3658
5292
  if (ch === "{") {
3659
- in_brace += 1;
3660
- markup += "{";
5293
+ in_brace = ρσ_list_iadd(in_brace, 1);
5294
+ markup = ρσ_list_iadd(markup, "{");
3661
5295
  } else if (ch === "}") {
3662
5296
  in_brace -= 1;
3663
5297
  if (in_brace > 0) {
3664
- markup += "}";
5298
+ markup = ρσ_list_iadd(markup, "}");
3665
5299
  } else {
3666
- ans += render_markup(markup);
5300
+ ans = ρσ_list_iadd(ans, render_markup(markup));
3667
5301
  }
3668
5302
  } else {
3669
- markup += ch;
5303
+ markup = ρσ_list_iadd(markup, ch);
3670
5304
  }
3671
5305
  } else {
3672
5306
  if (ch === "{") {
3673
- if (template[ρσ_bound_index(pos + 1, template)] === "{") {
3674
- pos += 1;
3675
- ans += "{";
5307
+ if (template[ρσ_bound_index(ρσ_list_add(pos, 1), template)] === "{") {
5308
+ pos = ρσ_list_iadd(pos, 1);
5309
+ ans = ρσ_list_iadd(ans, "{");
3676
5310
  } else {
3677
5311
  in_brace = 1;
3678
5312
  markup = "";
3679
5313
  }
3680
5314
  } else {
3681
- ans += ch;
3682
- if (ch === "}" && template[ρσ_bound_index(pos + 1, template)] === "}") {
3683
- pos += 1;
5315
+ ans = ρσ_list_iadd(ans, ch);
5316
+ if (ch === "}" && template[ρσ_bound_index(ρσ_list_add(pos, 1), template)] === "}") {
5317
+ pos = ρσ_list_iadd(pos, 1);
3684
5318
  }
3685
5319
  }
3686
5320
  }
3687
- pos += 1;
5321
+ pos = ρσ_list_iadd(pos, 1);
3688
5322
  }
3689
5323
  if (in_brace) {
3690
5324
  throw new ValueError("expected '}' before end of string");
@@ -3701,7 +5335,7 @@ define_str_func("capitalize", (function() {
3701
5335
  var string;
3702
5336
  string = this;
3703
5337
  if (string) {
3704
- string = string[0].toUpperCase() + string.slice(1).toLowerCase();
5338
+ string = ρσ_list_add(string[0].toUpperCase(), string.slice(1).toLowerCase());
3705
5339
  }
3706
5340
  return string;
3707
5341
  };
@@ -3716,7 +5350,7 @@ define_str_func("center", (function() {
3716
5350
  left = Math.floor((width - this.length) / 2);
3717
5351
  right = width - left - this.length;
3718
5352
  fill = fill || " ";
3719
- return new Array(left+1).join(fill) + this + new Array(right+1).join(fill);
5353
+ return ρσ_list_add(ρσ_list_add(new Array(left+1).join(fill), this), new Array(right+1).join(fill));
3720
5354
  };
3721
5355
  if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
3722
5356
  __argnames__ : {value: ["width", "fill"]},
@@ -3745,8 +5379,8 @@ define_str_func("count", (function() {
3745
5379
  while (pos !== -1) {
3746
5380
  pos = string.indexOf(needle, pos);
3747
5381
  if (pos !== -1) {
3748
- ans += 1;
3749
- pos += step;
5382
+ ans = ρσ_list_iadd(ans, 1);
5383
+ pos = ρσ_list_iadd(pos, step);
3750
5384
  }
3751
5385
  }
3752
5386
  return ans;
@@ -3792,7 +5426,7 @@ define_str_func("startswith", (function() {
3792
5426
  for (var i = 0; i < prefixes.length; i++) {
3793
5427
  prefix = prefixes[(typeof i === "number" && i < 0) ? prefixes.length + i : i];
3794
5428
  end = (end === undefined) ? this.length : end;
3795
- if (end - start >= prefix.length && prefix === this.slice(start, start + prefix.length)) {
5429
+ if (end - start >= prefix.length && prefix === this.slice(start, ρσ_list_add(start, prefix.length))) {
3796
5430
  return true;
3797
5431
  }
3798
5432
  }
@@ -3808,12 +5442,12 @@ define_str_func("find", (function() {
3808
5442
  var ρσ_anonfunc = function (needle, start, end) {
3809
5443
  var ans;
3810
5444
  while (start < 0) {
3811
- start += this.length;
5445
+ start = ρσ_list_iadd(start, this.length);
3812
5446
  }
3813
5447
  ans = this.indexOf(needle, start);
3814
5448
  if (end !== undefined && ans !== -1) {
3815
5449
  while (end < 0) {
3816
- end += this.length;
5450
+ end = ρσ_list_iadd(end, this.length);
3817
5451
  }
3818
5452
  if (ans >= end - needle.length) {
3819
5453
  return -1;
@@ -3831,12 +5465,12 @@ define_str_func("rfind", (function() {
3831
5465
  var ρσ_anonfunc = function (needle, start, end) {
3832
5466
  var ans;
3833
5467
  while (end < 0) {
3834
- end += this.length;
5468
+ end = ρσ_list_iadd(end, this.length);
3835
5469
  }
3836
5470
  ans = this.lastIndexOf(needle, end - 1);
3837
5471
  if (start !== undefined && ans !== -1) {
3838
5472
  while (start < 0) {
3839
- start += this.length;
5473
+ start = ρσ_list_iadd(start, this.length);
3840
5474
  }
3841
5475
  if (ans < start) {
3842
5476
  return -1;
@@ -3907,6 +5541,81 @@ define_str_func("isspace", (function() {
3907
5541
  });
3908
5542
  return ρσ_anonfunc;
3909
5543
  })());
5544
+ define_str_func("isalpha", (function() {
5545
+ var ρσ_anonfunc = function () {
5546
+ return this.length > 0 && /^[a-zA-Z]+$/.test(this);
5547
+ };
5548
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
5549
+ __module__ : {value: "__main__"}
5550
+ });
5551
+ return ρσ_anonfunc;
5552
+ })());
5553
+ define_str_func("isdigit", (function() {
5554
+ var ρσ_anonfunc = function () {
5555
+ return this.length > 0 && /^\d+$/.test(this);
5556
+ };
5557
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
5558
+ __module__ : {value: "__main__"}
5559
+ });
5560
+ return ρσ_anonfunc;
5561
+ })());
5562
+ define_str_func("isalnum", (function() {
5563
+ var ρσ_anonfunc = function () {
5564
+ return this.length > 0 && /^[a-zA-Z0-9]+$/.test(this);
5565
+ };
5566
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
5567
+ __module__ : {value: "__main__"}
5568
+ });
5569
+ return ρσ_anonfunc;
5570
+ })());
5571
+ define_str_func("isidentifier", (function() {
5572
+ var ρσ_anonfunc = function () {
5573
+ return this.length > 0 && /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(this);
5574
+ };
5575
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
5576
+ __module__ : {value: "__main__"}
5577
+ });
5578
+ return ρσ_anonfunc;
5579
+ })());
5580
+ define_str_func("casefold", (function() {
5581
+ var ρσ_anonfunc = function () {
5582
+ return this.toLowerCase();
5583
+ };
5584
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
5585
+ __module__ : {value: "__main__"}
5586
+ });
5587
+ return ρσ_anonfunc;
5588
+ })());
5589
+ define_str_func("removeprefix", (function() {
5590
+ var ρσ_anonfunc = function (prefix) {
5591
+ var s;
5592
+ s = this.toString();
5593
+ if (s.startsWith(prefix)) {
5594
+ return s.slice(prefix.length);
5595
+ }
5596
+ return s;
5597
+ };
5598
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
5599
+ __argnames__ : {value: ["prefix"]},
5600
+ __module__ : {value: "__main__"}
5601
+ });
5602
+ return ρσ_anonfunc;
5603
+ })());
5604
+ define_str_func("removesuffix", (function() {
5605
+ var ρσ_anonfunc = function (suffix) {
5606
+ var s;
5607
+ s = this.toString();
5608
+ if (suffix.length && s.endsWith(suffix)) {
5609
+ return s.slice(0, s.length - suffix.length);
5610
+ }
5611
+ return s;
5612
+ };
5613
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
5614
+ __argnames__ : {value: ["suffix"]},
5615
+ __module__ : {value: "__main__"}
5616
+ });
5617
+ return ρσ_anonfunc;
5618
+ })());
3910
5619
  define_str_func("join", (function() {
3911
5620
  var ρσ_anonfunc = function (iterable) {
3912
5621
  var ans, r;
@@ -3917,9 +5626,9 @@ define_str_func("join", (function() {
3917
5626
  r = iterable.next();
3918
5627
  while (!r.done) {
3919
5628
  if (ans) {
3920
- ans += this;
5629
+ ans = ρσ_list_iadd(ans, this);
3921
5630
  }
3922
- ans += r.value;
5631
+ ans = ρσ_list_iadd(ans, r.value);
3923
5632
  r = iterable.next();
3924
5633
  }
3925
5634
  return ans;
@@ -3936,7 +5645,7 @@ define_str_func("ljust", (function() {
3936
5645
  string = this;
3937
5646
  if (width > string.length) {
3938
5647
  fill = fill || " ";
3939
- string += new Array(width - string.length + 1).join(fill);
5648
+ string = ρσ_list_iadd(string, new Array(width - string.length + 1).join(fill));
3940
5649
  }
3941
5650
  return string;
3942
5651
  };
@@ -3952,7 +5661,7 @@ define_str_func("rjust", (function() {
3952
5661
  string = this;
3953
5662
  if (width > string.length) {
3954
5663
  fill = fill || " ";
3955
- string = new Array(width - string.length + 1).join(fill) + string;
5664
+ string = ρσ_list_add(new Array(width - string.length + 1).join(fill), string);
3956
5665
  }
3957
5666
  return string;
3958
5667
  };
@@ -3980,6 +5689,26 @@ define_str_func("upper", (function() {
3980
5689
  });
3981
5690
  return ρσ_anonfunc;
3982
5691
  })());
5692
+ define_str_func("title", (function() {
5693
+ var ρσ_anonfunc = function () {
5694
+ var words, title_cased_words, word;
5695
+ words = this.split(" ");
5696
+ title_cased_words = (function() {
5697
+ var ρσ_Iter = ρσ_Iterable(words), ρσ_Result = [], word;
5698
+ for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
5699
+ word = ρσ_Iter[ρσ_Index];
5700
+ ρσ_Result.push((word) ? ρσ_list_add(word[0].upper(), word.slice(1).lower()) : "");
5701
+ }
5702
+ ρσ_Result = ρσ_list_constructor(ρσ_Result);
5703
+ return ρσ_Result;
5704
+ })();
5705
+ return " ".join(title_cased_words);
5706
+ };
5707
+ if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, {
5708
+ __module__ : {value: "__main__"}
5709
+ });
5710
+ return ρσ_anonfunc;
5711
+ })());
3983
5712
  define_str_func("lstrip", (function() {
3984
5713
  var ρσ_anonfunc = function (chars) {
3985
5714
  var string, pos;
@@ -3987,7 +5716,7 @@ define_str_func("lstrip", (function() {
3987
5716
  pos = 0;
3988
5717
  chars = chars || ρσ_str.whitespace;
3989
5718
  while (chars.indexOf(string[(typeof pos === "number" && pos < 0) ? string.length + pos : pos]) !== -1) {
3990
- pos += 1;
5719
+ pos = ρσ_list_iadd(pos, 1);
3991
5720
  }
3992
5721
  if (pos) {
3993
5722
  string = string.slice(pos);
@@ -4010,7 +5739,7 @@ define_str_func("rstrip", (function() {
4010
5739
  pos -= 1;
4011
5740
  }
4012
5741
  if (pos < string.length - 1) {
4013
- string = string.slice(0, pos + 1);
5742
+ string = string.slice(0, ρσ_list_add(pos, 1));
4014
5743
  }
4015
5744
  return string;
4016
5745
  };
@@ -4037,7 +5766,7 @@ define_str_func("partition", (function() {
4037
5766
  if (idx === -1) {
4038
5767
  return [this, "", ""];
4039
5768
  }
4040
- return [this.slice(0, idx), sep, this.slice(idx + sep.length)];
5769
+ return [this.slice(0, idx), sep, this.slice(ρσ_list_add(idx, sep.length))];
4041
5770
  };
4042
5771
  if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
4043
5772
  __argnames__ : {value: ["sep"]},
@@ -4052,7 +5781,7 @@ define_str_func("rpartition", (function() {
4052
5781
  if (idx === -1) {
4053
5782
  return ["", "", this];
4054
5783
  }
4055
- return [this.slice(0, idx), sep, this.slice(idx + sep.length)];
5784
+ return [this.slice(0, idx), sep, this.slice(ρσ_list_add(idx, sep.length))];
4056
5785
  };
4057
5786
  if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
4058
5787
  __argnames__ : {value: ["sep"]},
@@ -4078,8 +5807,8 @@ define_str_func("replace", (function() {
4078
5807
  if (idx === -1) {
4079
5808
  break;
4080
5809
  }
4081
- pos = idx + repl.length;
4082
- string = string.slice(0, idx) + repl + string.slice(idx + old.length);
5810
+ pos = ρσ_list_add(idx, repl.length);
5811
+ string = ρσ_list_add(ρσ_list_add(string.slice(0, idx), repl), string.slice(ρσ_list_add(idx, old.length)));
4083
5812
  }
4084
5813
  return string;
4085
5814
  };
@@ -4102,13 +5831,13 @@ define_str_func("split", (function() {
4102
5831
  extra = "";
4103
5832
  parts = [];
4104
5833
  for (var i = 0; i < ans.length; i++) {
4105
- if (parts.length >= maxsplit + 1) {
4106
- extra += ans[(typeof i === "number" && i < 0) ? ans.length + i : i];
5834
+ if (parts.length >= ρσ_list_add(maxsplit, 1)) {
5835
+ extra = ρσ_list_iadd(extra, ans[(typeof i === "number" && i < 0) ? ans.length + i : i]);
4107
5836
  } else if (i % 2 === 0) {
4108
5837
  parts.push(ans[(typeof i === "number" && i < 0) ? ans.length + i : i]);
4109
5838
  }
4110
5839
  }
4111
- parts[parts.length-1] += extra;
5840
+ parts[parts.length-1] = ρσ_list_iadd(parts[parts.length-1], extra);
4112
5841
  ans = parts;
4113
5842
  } else {
4114
5843
  ans = split(this, /\s+/);
@@ -4159,11 +5888,11 @@ define_str_func("rsplit", (function() {
4159
5888
  }
4160
5889
  current = ch;
4161
5890
  } else {
4162
- current += ch;
5891
+ current = ρσ_list_iadd(current, ch);
4163
5892
  }
4164
5893
  pos -= 1;
4165
5894
  }
4166
- ans.push(this.slice(0, pos + 1) + current);
5895
+ ans.push(ρσ_list_add(this.slice(0, ρσ_list_add(pos, 1)), current));
4167
5896
  ans.reverse();
4168
5897
  } else {
4169
5898
  ans = split(this, /\s+/);
@@ -4180,7 +5909,7 @@ define_str_func("rsplit", (function() {
4180
5909
  if (idx === -1) {
4181
5910
  break;
4182
5911
  }
4183
- ans.push(this.slice(idx + sep.length, end));
5912
+ ans.push(this.slice(ρσ_list_add(idx, sep.length), end));
4184
5913
  pos = idx - 1;
4185
5914
  end = idx;
4186
5915
  }
@@ -4206,7 +5935,7 @@ define_str_func("splitlines", (function() {
4206
5935
  if (i % 2 === 0) {
4207
5936
  ans.push(parts[(typeof i === "number" && i < 0) ? parts.length + i : i]);
4208
5937
  } else {
4209
- ans[ans.length-1] += parts[(typeof i === "number" && i < 0) ? parts.length + i : i];
5938
+ ans[ans.length-1] = ρσ_list_iadd(ans[ans.length-1], parts[(typeof i === "number" && i < 0) ? parts.length + i : i]);
4210
5939
  }
4211
5940
  }
4212
5941
  } else {
@@ -4244,7 +5973,7 @@ define_str_func("zfill", (function() {
4244
5973
  var string;
4245
5974
  string = this;
4246
5975
  if (width > string.length) {
4247
- string = new Array(width - string.length + 1).join("0") + string;
5976
+ string = ρσ_list_add(new Array(width - string.length + 1).join("0"), string);
4248
5977
  }
4249
5978
  return string;
4250
5979
  };
@@ -4254,6 +5983,39 @@ define_str_func("zfill", (function() {
4254
5983
  });
4255
5984
  return ρσ_anonfunc;
4256
5985
  })());
5986
+ define_str_func("expandtabs", (function() {
5987
+ var ρσ_anonfunc = function (tabsize) {
5988
+ var string, ans, col, ch, spaces;
5989
+ if (tabsize === undefined) {
5990
+ tabsize = 8;
5991
+ }
5992
+ string = this;
5993
+ ans = "";
5994
+ col = 0;
5995
+ for (var i = 0; i < string.length; i++) {
5996
+ ch = string[(typeof i === "number" && i < 0) ? string.length + i : i];
5997
+ if (ch === "\t") {
5998
+ if (tabsize > 0) {
5999
+ spaces = tabsize - col % tabsize;
6000
+ ans = ρσ_list_iadd(ans, new Array(spaces + 1).join(" "));
6001
+ col = ρσ_list_iadd(col, spaces);
6002
+ }
6003
+ } else if (ch === "\n" || ch === "\r") {
6004
+ ans = ρσ_list_iadd(ans, ch);
6005
+ col = 0;
6006
+ } else {
6007
+ ans = ρσ_list_iadd(ans, ch);
6008
+ col = ρσ_list_iadd(col, 1);
6009
+ }
6010
+ }
6011
+ return ans;
6012
+ };
6013
+ if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
6014
+ __argnames__ : {value: ["tabsize"]},
6015
+ __module__ : {value: "__main__"}
6016
+ });
6017
+ return ρσ_anonfunc;
6018
+ })());
4257
6019
  ρσ_str.uchrs = (function() {
4258
6020
  var ρσ_anonfunc = function (string, with_positions) {
4259
6021
  return (function(){
@@ -4349,7 +6111,7 @@ define_str_func("zfill", (function() {
4349
6111
  ans = 0;
4350
6112
  while (!r.done) {
4351
6113
  r = iterator.next();
4352
- ans += 1;
6114
+ ans = ρσ_list_iadd(ans, 1);
4353
6115
  }
4354
6116
  return ans;
4355
6117
  };
@@ -4367,4 +6129,19 @@ define_str_func("zfill", (function() {
4367
6129
  ρσ_str.printable = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\u000b\f";
4368
6130
  ρσ_str.whitespace = " \t\n\r\u000b\f";
4369
6131
  define_str_func = undefined;
4370
- var str = ρσ_str, repr = ρσ_repr;
6132
+ function ρσ_format(value, spec) {
6133
+ if (value !== null && value !== undefined && typeof value.__format__ === "function") {
6134
+ return value.__format__((spec !== undefined) ? spec : "");
6135
+ }
6136
+ if (spec === undefined || spec === "") {
6137
+ return ρσ_str(value);
6138
+ }
6139
+ return str.format(ρσ_list_add(ρσ_list_add("{:", spec), "}"), value);
6140
+ };
6141
+ if (!ρσ_format.__argnames__) Object.defineProperties(ρσ_format, {
6142
+ __argnames__ : {value: ["value", "spec"]},
6143
+ __module__ : {value: "__main__"}
6144
+ });
6145
+
6146
+ ρσ_str.__name__ = "str";
6147
+ var str = ρσ_str, repr = ρσ_repr, format = ρσ_format;