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
## | |
# Copyright (c) 2011 Sprymix Inc. | |
# All rights reserved. | |
# | |
# See LICENSE for details. | |
## | |
import inspect | |
import collections |
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
def render_signature(signature): | |
'''Renders function definition by its signature. | |
Example: | |
>>> def test(a:'foo', *, b:'bar', c=True, **kwargs:None) -> 'spam': | |
... pass | |
>>> render_signature(inspect.signature(test)) | |
test(a:'foo', *, b:'bar', c=True, **kwargs:None) -> 'spam' |
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
## | |
# Copyright 2013 Yury Selivanov <[email protected]> | |
# License: MIT | |
## | |
import code | |
import subprocess | |
import os | |
import sys |
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 asyncio | |
import time | |
I = 0 | |
def test2(): | |
yield from () | |
global I | |
I += 1 |
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
log_level = logger.getEffectiveLevel() | |
if log_level <= INFO: | |
t0 = self.time() | |
event_list = self._selector.select(timeout) | |
t1 = self.time() | |
argstr = '' if timeout is None else ' {:.3f}'.format(timeout) | |
if t1-t0 >= 1: | |
level = logging.INFO | |
logger.log(level, 'poll%s took %.3f seconds', argstr, t1-t0) | |
elif log_level <= DEBUG: |
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
====================================================================== | |
FAIL: test_builtins (idlelib.idle_test.test_calltips.Get_signatureTest) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/Users/yury/dev/py/cpython/Lib/idlelib/idle_test/test_calltips.py", line 59, in test_builtins | |
'x.__init__(...) initializes x; see help(type(x)) for signature') | |
File "/Users/yury/dev/py/cpython/Lib/idlelib/idle_test/test_calltips.py", line 53, in gtest | |
self.assertEqual(signature(obj), out) | |
AssertionError: 'Initializes self. See help(type(self)) for accurate signature.' != 'x.__init__(...) initializes x; see help(type(x)) for signature' | |
- Initializes self. See help(type(self)) for accurate signature. |
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 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 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/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 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
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 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 asyncio | |
import time | |
import statistics | |
import heapq | |
ITERS = 2000 | |
NUMBER_OF_TASKS = 100000 | |
loop = asyncio.get_event_loop() |
OlderNewer