This file contains 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 inspect | |
def inherit(*, base, docs=False, signature=False): | |
assert docs or signature | |
assert isinstance(base, type) # we can also support functions | |
def wrap(func): | |
base_func = getattr(base, func.__name__) |
This file contains 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/Lib/inspect.py Thu Feb 06 22:06:16 2014 -0500 | |
> +++ b/Lib/inspect.py Fri Feb 07 13:41:22 2014 -0500 | |
< +def _strip_non_python_syntax(signature): | |
--- | |
> +def _signature_strip_non_python_syntax(signature): | |
> + # Internal helper to convert AC extended signature format | |
> + # to the standard Python syntax | |
> + | |
99a103,106 | |
> - if first_parameter_is_self: |
This file contains 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
class Local: | |
def __getattr__(self, attr): | |
# finds 'attr' stored for the current Task.context_id | |
def __setattr__(self, attr, val): | |
# stores value for the current Task.context_id | |
local = Local() | |
This file contains 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 asyncio | |
import time | |
import statistics | |
import heapq | |
ITERS = 2000 | |
NUMBER_OF_TASKS = 100000 | |
loop = asyncio.get_event_loop() |
This file contains 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 asyncio | |
from aiohttp.server import ServerHttpProtocol | |
import unittest | |
import threading | |
from urllib.request import urlopen, URLError | |
class Test(unittest.TestCase): | |
def setUp(self): | |
import logging |
This file contains 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
// Read this first: http://code.activestate.com/recipes/393090/ | |
function sum(ar) { | |
var c = ar.length; | |
var s = 0; | |
for (var i = 0; i < c; i++) { | |
s += ar[i]; | |
} | |
return s; | |
} |
This file contains 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 os | |
import sys | |
import token | |
import tokenize | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
print('pass directory to search in as an arg') | |
sys.exit(1) |
This file contains 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 | |
import time | |
# import sys | |
# sys.set_generator_wrapper(lambda x: x) | |
def binary(n): | |
if n <= 0: | |
return 1 |
This file contains 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
class CM: | |
def __enter__(self): | |
global CNT1 | |
CNT1 +=1 | |
def __exit__(self, et, e, tv): | |
global CNT2 | |
CNT2 += 1 | |
This file contains 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
diff --git a/Grammar/Grammar b/Grammar/Grammar | |
index 94898d3..9c74096 100644 | |
--- a/Grammar/Grammar | |
+++ b/Grammar/Grammar | |
@@ -21,8 +21,11 @@ eval_input: testlist NEWLINE* ENDMARKER | |
decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE | |
decorators: decorator+ | |
-decorated: decorators (classdef | funcdef) | |
-funcdef: 'def' NAME parameters ['->' test] ':' suite |
OlderNewer