This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| t = ['a']*1000 | |
| t0 = time.time() | |
| for x in t: | |
| for y in t: | |
| a = 1 | |
| print("assignment.py", time.time()-t0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''import time\n\nt = ['a']*1000\n\nt0 = time.time()\nfor x in t:\n for y in t:\n a = 1\nprint("assignment.py", time.time()-t0)\n\nt0 = time.time()\na = 0\nfor x in t:\n for y in t:\n a += 1\nprint("augm_assign.py", time.time()-t0)\n\nt0 = time.time()\nfor x in t:\n for y in t:\n a = 1.0\nprint("assignment_float.py", time.time()-t0)\n\nt0 = time.time()\nfor x in t:\n for y in t:\n a = {0:0}\nprint("build_dict.py", time.time()-t0)\n\nt0 = time.time()\na = {0:0}\n\nfor x in t:\n for y in t:\n a[0] = y\n\nprint("set_dict_item.py", time.time()-t0)\n\nt0 = time.time()\nfor x in t:\n for y in t:\n a = [1, 2, 3]\nprint("build_list.py", time.time()-t0)\n\nt0 = time.time()\na = [0]\n\nfor x in t:\n for y in t:\n a[0] = y\nprint("set_list_item.py", time.time()-t0)\n\nt0 = time.time()\na, b, c = 1, 2, 3\nfor x in t:\n for y in t:\n a + b + c\nprint("add_integers.py", time.time()-t0)\n\nt0 = time.time()\na, b, c = 'a', 'b', 'c'\nfor x in t:\n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| t0 = time.time() | |
| for i in xrange(1000000): | |
| a = 1 | |
| print("assignment.py", time.time()-t0) | |
| t0 = time.time() | |
| a = 0 | |
| for i in xrange(1000000): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''import time\n\nt0 = time.time()\nfor i in xrange(1000000):\n a = 1\nprint("assignment.py", time.time()-t0)\n\nt0 = time.time()\na = 0\nfor i in xrange(1000000):\n a += 1\nprint("augm_assign.py", time.time()-t0)\n\nt0 = time.time()\nfor i in xrange(1000000):\n a = 1.0\nprint("assignment_float.py", time.time()-t0)\n\nt0 = time.time()\nfor i in xrange(1000000):\n a = {0:0}\nprint("build_dict.py", time.time()-t0)\n\nt0 = time.time()\na = {0:0}\n\nfor i in xrange(1000000):\n a[0] = i\n\nassert a[0]==999999\nprint("set_dict_item.py", time.time()-t0)\n\nt0 = time.time()\nfor i in xrange(1000000):\n a = [1, 2, 3]\nprint("build_list.py", time.time()-t0)\n\nt0 = time.time()\na = [0]\n\nfor i in xrange(1000000):\n a[0] = i\nprint("set_list_item.py", time.time()-t0)\n\nt0 = time.time()\na, b, c = 1, 2, 3\nfor i in xrange(1000000):\n a + b + c\nprint("add_integers.py", time.time()-t0)\n\nt0 = time.time()\na, b, c = 'a', 'b', 'c'\nfor i in xrange(1000000):\n a + b + c\nprint("add_strings.py", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| With xrange for pypy.js and skulpt | |
| Code for Skulpt : https://gist.github.com/PierreQuentel/c2286b5795d920e5262b | |
| Code for pypy.js : https://gist.github.com/PierreQuentel/9507d182bce901a33d1b | |
| | x slower than Cpython | |
| Cpython Brython pypy.js skulpt | Brython pypy.js skulpt | |
| assignment 125 14 3245 5936 | 0.11 26.05 47.64 | |
| augm_assign 211 44 4105 6659 | 0.21 19.49 31.61 | |
| assignment_float 110 508 3384 6027 | 4.63 30.85 54.94 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Code for CPython, Brython and Skulpt : https://gist.github.com/PierreQuentel/50047f7d15b2e7d41516 | |
| Code for pypy.js : https://gist.github.com/PierreQuentel/d9b2c037089cd7361d42 | |
| | x slower than Cpython | |
| Cpython Brython pypy.js skulpt | Brython pypy.js skulpt | |
| assignment 112 1175 3961 5494 | 10.52 35.45 49.18 | |
| augm_assign 185 1744 4721 6533 | 9.42 25.51 35.30 | |
| assignment_float 117 2244 4112 5795 | 19.23 35.23 49.65 | |
| build_dict 369 7582 4398 13805 | 20.53 11.91 37.38 | |
| set_dict_item 188 1495 5492 22455 | 7.95 29.20 119.40 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"/> | |
| <script type="text/javascript" src="http://rawgit.com/brython-dev/brython/master/www/src/brython.js"></script> | |
| </head> | |
| <body onload="brython(2);test()"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ast | |
| src = """import X | |
| from Y import ( | |
| A, b) | |
| def f(): | |
| pass | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A revised version of CPython's turtle module written for Brython | |
| # | |
| # Note: This version is not intended to be used in interactive mode, | |
| # nor use help() to look up methods/functions definitions. The docstrings | |
| # have thus been shortened considerably as compared with the CPython's version. | |
| # | |
| # All public methods/functions of the CPython version should exist, if only | |
| # to print out a warning that they are not implemented. The intent is to make | |
| # it easier to "port" any existing turtle program from CPython to the browser. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from browser import ajax | |
| req = ajax.Ajax() | |
| class Finder: | |
| """Meta path finder, searches Python modules or packages in the | |
| application directory.""" | |
| @classmethod |
OlderNewer