id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
185,931 | import fnmatch
import glob
import os
import os.path
import shutil
import stat
from .iterutil import iter_many
S_IRANY = stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH
def _get_file_info(file):
filename = st = mode = None
if isinstance(file, int):
mode = file
elif isinstance(file, os.stat_result):
... | null |
185,932 | import fnmatch
import glob
import os
import os.path
import shutil
import stat
from .iterutil import iter_many
S_IWANY = stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH
def _get_file_info(file):
def _check_file(filename, check):
def _check_mode(st, mode, check, user):
def is_writable(file, *, user=None, check=False):
fi... | null |
185,933 | def chain_test(n):
"""
This is the standard DeltaBlue benchmark. A long chain of equality
constraints is constructed with a stay constraint on one end. An
edit constraint is then added to the opposite end and the time is
measured for adding and removing this constraint, and extracting
and execut... | null |
185,934 | from __future__ import annotations
import __static__
from __static__ import cast
import sys
from typing import Final, List
tracing: bool = False
def trace(a):
taskWorkArea: Final[TaskWorkArea] = TaskWorkArea()
class Task(TaskState):
def __init__(self, i: int, p: int, w: Packet | None, initialState: TaskState, r: T... | null |
185,935 | from __future__ import annotations
import __static__
from __static__ import int64, box
from typing import Callable, List
class int64(int):
pass
def box(o):
return o
Callable = _CallableType(collections.abc.Callable, 2)
Callable.__doc__ = \
"""Callable type; Callable[[int], ... | null |
185,936 | def bench_n_queens(queen_count):
return list(n_queens(queen_count))
def run():
queen_count = 8
bench_n_queens(queen_count) | null |
185,938 | DEFAULT_ITERATIONS = 20000
DEFAULT_REFERENCE = "sun"
def bench_nbody(loops, reference, iterations):
# Set up global state
offset_momentum(BODIES[reference])
range_it = range(loops)
for _ in range_it:
report_energy()
advance(0.01, iterations)
report_energy()
def run():
num_lo... | null |
185,939 | from __future__ import annotations
import __static__
from __static__ import CheckedList, cast
from typing import final
from enum import IntEnum
def chain_test(n: int) -> None:
"""
This is the standard DeltaBlue benchmark. A long chain of equality
constraints is constructed with a stay constraint on one end.... | null |
185,940 | DEFAULT_ARG = 9
def fannkuch(n):
count = list(range(1, n + 1))
max_flips = 0
m = n - 1
r = n
perm1 = list(range(n))
perm = list(range(n))
perm1_ins = perm1.insert
perm1_pop = perm1.pop
while 1:
while r != 1:
count[r - 1] = r
r -= 1
if perm1[0] ... | null |
185,941 | from __future__ import annotations
import __static__
from __static__ import box, int64, Array
ArrayI64 = Array[int64]
class int64(int):
pass
def box(o):
return o
def fannkuch(nb: int) -> int:
n: int64 = int64(nb)
count: ArrayI64 = ArrayI64(range(1, nb + 1))
max_flip... | null |
185,942 | from __future__ import annotations
import __static__
from __static__ import int64, box, Array, cbool, clen
from typing import List, Generator, Iterator
ArrayI64 = Array[int64]
def solve(queen_count: int) -> Iterator[ArrayI64]:
"""N-Queens solver.
Args:
queen_count: the number of queens to solve for. Thi... | Return all the possible valid configurations of the queens in a board of size queen_count. See solve method to understand it better |
185,943 | from __future__ import annotations
import __static__
from __static__ import cast
from typing import Final, List
LOOPS: Final[int] = 50000
def pystones(loops=LOOPS):
def run() -> None:
loops: int = LOOPS
pystones(loops) | null |
185,944 | import __static__
from __static__ import double, CheckedList, CheckedDict, box
The provided code snippet includes necessary dependencies for implementing the `combinations` function. Write a Python function `def combinations(l)` to solve the following problem:
Pure-Python implementation of itertools.combinations(l, 2)... | Pure-Python implementation of itertools.combinations(l, 2). |
185,945 | import __static__
from __static__ import double, CheckedList, CheckedDict, box
DEFAULT_ITERATIONS = 20000
DEFAULT_REFERENCE = "sun"
def bench_nbody(loops, reference, iterations):
# Set up global state
offset_momentum(BODIES[reference], SYSTEM)
range_it = range(loops)
for _ in range_it:
report_en... | null |
185,946 | from __future__ import annotations
import __static__
from typing import Generator, Tuple, Iterator
def n_queens(queen_count: int) -> Iterator[List[int]]:
"""N-Queens solver.
Args:
queen_count: the number of queens to solve for. This is also the
board size.
Yields:
Solutions to th... | null |
185,947 | import sys
tracing = False
def trace(a):
taskWorkArea = TaskWorkArea()
def schedule():
t = taskWorkArea.taskList
while t is not None:
if tracing:
print("tcb =", t.ident)
if t.isTaskHoldingOrWaiting():
t = t.link
else:
if tracing:
trac... | null |
185,948 | import __static__
from typing import List, Mapping, Tuple, TypeVar
T = TypeVar("T")
Tuple = _TupleType(tuple, -1, inst=False, name='Tuple')
Tuple.__doc__ = \
"""Tuple type; Tuple[X, Y] is the cross-product type of X and Y.
Example: Tuple[T1, T2] is a tuple of two elements corresponding
to type variables T... | Pure-Python implementation of itertools.combinations(l, 2). |
185,949 | import __static__
from typing import List, Mapping, Tuple, TypeVar
DEFAULT_ITERATIONS: int = 20000
DEFAULT_REFERENCE: str = "sun"
def bench_nbody(loops: int, reference: str, iterations: int):
# Set up global state
offset_momentum(BODIES[reference])
range_it = range(loops)
for _ in range_it:
repo... | null |
185,950 | import asyncio
import math
import random
import time
from argparse import ArgumentParser
DEFAULT_MEMOIZABLE_PERCENTAGE = 90
DEFAULT_CPU_PROBABILITY = 0.5
class ArgumentParser(_AttributeHolder, _ActionsContainer):
"""Object for parsing command line strings into Python objects.
Keyword Arguments:
- prog... | null |
185,951 | LOOPS = 50000
def pystones(loops=LOOPS):
Proc0(loops)
def run():
loops = LOOPS
pystones(loops) | null |
185,952 | from __future__ import annotations
import __static__
from __static__ import CheckedList, box, cast, cbool, clen, int64, inline
from typing import final
from enum import IntEnum
class Strength:
def __init__(self, strength: int64, name: str) -> None:
self.strength: int64 = strength
self.name: str = na... | null |
185,953 | from __future__ import annotations
import __static__
from __static__ import CheckedList, box, cast, cbool, clen, int64, inline
from typing import final
from enum import IntEnum
class Strength:
def __init__(self, strength: int64, name: str) -> None:
self.strength: int64 = strength
self.name: str = na... | null |
185,954 | from __future__ import annotations
import __static__
from __static__ import CheckedList, box, cast, cbool, clen, int64, inline
from typing import final
from enum import IntEnum
class Strength:
def __init__(self, strength: int64, name: str) -> None:
def next_weaker(self) -> Strength:
def weakest_of(s1: Streng... | null |
185,955 | from __future__ import annotations
import __static__
from __static__ import CheckedList, box, cast, cbool, clen, int64, inline
from typing import final
from enum import IntEnum
def chain_test(n: int64) -> None:
"""
This is the standard DeltaBlue benchmark. A long chain of equality
constraints is constructed... | null |
185,956 | from __future__ import annotations
import __static__
from __static__ import cast, cbool, int64, box, inline
from typing import Final, Optional, List
from typing import Optional
class TaskState(object):
def __init__(self) -> None:
self.packet_pending: cbool = True
self.task_waiting: cbool = False
... | null |
185,957 | from __future__ import annotations
import __static__
from typing import Callable, List
Callable = _CallableType(collections.abc.Callable, 2)
Callable.__doc__ = \
"""Callable type; Callable[[int], str] is a function of (int) -> str.
The subscription syntax must always be used with exactly two
values: the a... | null |
185,958 | from __future__ import annotations
import __static__
from __static__ import cast
from typing import final
def chain_test(n: int) -> None:
def projection_test(n: int) -> None:
def delta_blue(n: int) -> None:
chain_test(n)
projection_test(n) | null |
185,966 | import sys
import os
import marshal
The provided code snippet includes necessary dependencies for implementing the `get_module_code` function. Write a Python function `def get_module_code(filename)` to solve the following problem:
Compile 'filename' and return the module code as a marshalled byte string.
Here is the ... | Compile 'filename' and return the module code as a marshalled byte string. |
185,967 | import sys
import os
import marshal
SYMBOL = 'M___hello__'
The provided code snippet includes necessary dependencies for implementing the `gen_c_code` function. Write a Python function `def gen_c_code(fp, co_bytes)` to solve the following problem:
Generate C code for the module code in 'co_bytes', write it to 'fp'.
H... | Generate C code for the module code in 'co_bytes', write it to 'fp'. |
185,995 | import locale
import sys
def check(data):
def optimize(data):
locale_alias = locale.locale_alias
locale.locale_alias = data.copy()
for k, v in data.items():
del locale.locale_alias[k]
if locale.normalize(k) != v:
locale.locale_alias[k] = v
newdata = locale.locale_alias
e... | null |
186,009 | from __future__ import print_function
import gdb
import os
import locale
import sys
def pformat(object, indent=1, width=80, depth=None, *,
compact=False, sort_dicts=True, underscore_numbers=False):
"""Format a Python object into a pretty-printed representation."""
return PrettyPrinter(indent=indent... | null |
186,010 | from __future__ import print_function
import gdb
import os
import locale
import sys
def pretty_printer_lookup(gdbval):
type = gdbval.type.unqualified()
if type.code != gdb.TYPE_CODE_PTR:
return None
type = type.target().unqualified()
t = str(type)
if t in ("PyObject", "PyFrameObject", "PyUni... | null |
186,011 | from __future__ import print_function
import gdb
import os
import locale
import sys
class Frame(object):
'''
Wrapper for gdb.Frame, adding various methods
'''
def __init__(self, gdbframe):
self._gdbframe = gdbframe
def older(self):
older = self._gdbframe.older()
if older:
... | Move up or down the stack (for the py-up/py-down command) |
186,012 | from __future__ import print_function
import gdb
import os
import locale
import sys
class PyTraceBreakpoint(gdb.Breakpoint):
def __init__(self):
super().__init__('gdb_tracefunc')
self.silent = True
def stop(self):
global _PyRunningTargetFrameAddress
global _PyRunningTargetFrameBa... | null |
186,013 | import abc
import argparse
import collections
import io
import locale
import re
import shlex
import struct
import lldb
import six
def write_string(result, string, end=u'\n', encoding=locale.getpreferredencoding()):
"""Helper function for writing to SBCommandReturnObject that expects bytes on py2 and str on py3."""
... | Print a short summary of a given Python frame: module and the line being executed. |
186,014 | import abc
import argparse
import collections
import io
import locale
import re
import shlex
import struct
import lldb
import six
class PyFrameObject(PyObject):
typename = 'frame'
def __init__(self, lldb_value):
super(PyFrameObject, self).__init__(lldb_value)
self.co = PyCodeObject(self.child('f... | Select and return the closest Python frame (or do nothing if the current frame is a Python frame). |
186,015 | import abc
import argparse
import collections
import io
import locale
import re
import shlex
import struct
import lldb
import six
The provided code snippet includes necessary dependencies for implementing the `is_available` function. Write a Python function `def is_available(lldb_value)` to solve the following problem... | Helper function to check if a variable is available and was not optimized out. |
186,016 | import abc
import argparse
import collections
import io
import locale
import re
import shlex
import struct
import lldb
import six
ENCODING_RE = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)')
The provided code snippet includes necessary dependencies for implementing the `source_file_encoding` function. W... | Determine the text encoding of a Python source file. |
186,017 | import abc
import argparse
import collections
import io
import locale
import re
import shlex
import struct
import lldb
import six
The provided code snippet includes necessary dependencies for implementing the `source_file_lines` function. Write a Python function `def source_file_lines(filename, start, end, encoding='u... | Return the contents of [start; end) lines of the source file. 1 based indexing is used for convenience. |
186,018 | import abc
import argparse
import collections
import io
import locale
import re
import shlex
import struct
import lldb
import six
The provided code snippet includes necessary dependencies for implementing the `general_purpose_registers` function. Write a Python function `def general_purpose_registers(frame)` to solve ... | Return a list of general purpose register names. |
186,019 | import abc
import argparse
import collections
import io
import locale
import re
import shlex
import struct
import lldb
import six
def register_commands(debugger):
for cls in Command.__subclasses__():
debugger.HandleCommand(
'command script add -c cpython_lldb.{cls} {command}'.format(
... | null |
186,039 | from test.test_importlib import util
import decimal
import imp
import importlib
import importlib.machinery
import json
import os
import py_compile
import sys
import tabnanny
import timeit
def bench(name, cleanup=lambda: None, *, seconds=1, repeat=3):
if __name__ == '__main__':
import argparse
parser = argparse.... | null |
186,043 | import re, os, marshal, codecs
def readmap(filename):
with open(filename) as f:
lines = f.readlines()
enc2uni = {}
identity = []
unmapped = list(range(256))
# UTC mapping tables per convention don't include the identity
# mappings for code points 0x00 - 0x1F and 0x7F, unless these are
... | null |
186,061 | import re
from unicodedata import ucd_3_2_0 as unicodedata
def map_table_b3(code):
r = b3_exceptions.get(ord(code))
if r is not None: return r
return code.lower()
def map_table_b2(a):
al = map_table_b3(a)
b = unicodedata.normalize("NFKC", al)
bl = "".join([map_table_b3(ch) for ch in b])
c =... | null |
186,153 | import timeit
import itertools
import operator
import re
import sys
import datetime
import optparse
_RANGE_10 = list(range(10))
def _get_dna(STR):
def split_multichar_sep_dna(STR):
s = _get_dna(STR)
s_split = s.split
pat = STR("ACTAT")
for x in _RANGE_10:
s_split(pat) | null |
186,159 | import timeit
import itertools
import operator
import re
import sys
import datetime
import optparse
_RANGE_10 = list(range(10))
def _get_2000_lines(STR):
def count_newlines(STR):
s = _get_2000_lines(STR)
s_count = s.count
nl = STR("\n")
for x in _RANGE_10:
s_count(nl) | null |
186,179 | import timeit
import itertools
import operator
import re
import sys
import datetime
import optparse
_RANGE_10 = list(range(10))
def _get_2000_lines(STR):
if STR is UNICODE:
return _text_with_2000_lines_unicode
if STR is BYTES:
return _text_with_2000_lines_bytes
raise AssertionError
def repl... | null |
186,190 | import sys
import argparse
from pprint import pprint
def pprint(object, stream=None, indent=1, width=80, depth=None, *,
compact=False, sort_dicts=True, underscore_numbers=False):
"""Pretty-print a Python object to a stream [default is sys.stdout]."""
printer = PrettyPrinter(
stream=stream, i... | null |
186,194 | import sys, os, difflib, argparse
from datetime import datetime, timezone
class datetime(date):
def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
microsecond=0, tzinfo=None, *, fold=0):
def hour(self):
def minute(self):
def second(self):
def microseco... | null |
186,195 | import difflib
import re
import shlex
import subprocess
from typing import Dict, List, Union
def Union(self, parameters):
"""Union type; Union[X, Y] means either X or Y.
To define a union, use e.g. Union[int, str]. Details:
- The arguments must be types and there must be at least one.
- None as an ar... | Run a 'cmd', returning stdout as a list of strings. |
186,196 | import difflib
import re
import shlex
import subprocess
from typing import Dict, List, Union
def _split_diff_to_context_free_file_diffs(
diff: List[str], src: str) -> Dict[str, List[str]]:
"""Take a noisy diff-like input covering many files and return a purified
map of file name -> hunk changes. Strips ... | null |
186,199 | import sys
import itertools
class RecursiveBlowup4:
def __add__(self, x):
return x + self
def test_add():
return RecursiveBlowup4() + RecursiveBlowup4() | null |
186,207 | import argparse
import dis
import types
from typing import Dict, List, Tuple
Histogram = Dict[str, int]
def count_bytecode(func: types.FunctionType, histo: Histogram) -> None:
"""Return a distribution of bytecode in func"""
for instr in dis.get_instructions(func):
if instr.opname in histo:
h... | Compute the bytecode histogram of all functions reachable from obj |
186,208 | import argparse
import dis
import types
from typing import Dict, List, Tuple
CountAssocs = List[Tuple[str, int]]
Histogram = Dict[str, int]
def sort_alpha(histo: Histogram) -> CountAssocs:
ordered = sorted(histo.items(), key=lambda p: p[0])
return list(ordered) | null |
186,209 | import argparse
import dis
import types
from typing import Dict, List, Tuple
CountAssocs = List[Tuple[str, int]]
Histogram = Dict[str, int]
def sort_count(histo: Histogram) -> CountAssocs:
ordered = sorted(histo.items(), key=lambda p: p[1], reverse=True)
return list(ordered) | null |
186,217 | NT_OFFSET = 256
def load_tokens(path):
def update_file(file, content):
token_h_template = """\
/* Auto-generated by Tools/scripts/generate_token.py */
/* Token types */
#ifndef Py_LIMITED_API
#ifndef Py_TOKEN_H
#define Py_TOKEN_H
#ifdef __cplusplus
extern "C" {
#endif
#undef TILDE /* Prevent clash of our definition w... | null |
186,218 | def load_tokens(path):
def update_file(file, content):
token_c_template = """\
/* Auto-generated by Tools/scripts/generate_token.py */
#include "Python.h"
#include "token.h"
/* Token names */
const char * const _PyParser_TokenNames[] = {
%s\
};
/* Return the token corresponding to a single character */
int
PyToken_OneC... | null |
186,223 | STEPSIZE = 8
TABSIZE = 8
EXPANDTABS = False
import io
import re
import sys
class PythonIndenter:
def __init__(self, fpi = sys.stdin, fpo = sys.stdout,
indentsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS):
def write(self, line):
def readline(self):
def error(self, f... | null |
186,229 | import sys
from dataclasses import dataclass
class Entry:
base: int
size: int
name: str
def load_perf_map(filepath):
result = []
with open(filepath, "r") as perfmap:
for line in perfmap.readlines():
line = line.strip()
b, s, n = line.split(" ")
entry = En... | null |
186,231 | import functools
import sys
import tokenize
UINT32_MASK = (1<<32)-1
def write_int_array_from_ops(name, ops, out):
bits = 0
for op in ops:
bits |= 1<<op
out.write(f"static uint32_t {name}[8] = {{\n")
for i in range(8):
out.write(f" {bits & UINT32_MASK}U,\n")
bits >>= 32
as... | null |
186,238 | import argparse
import dis
import marshal
import sys
from types import CodeType
def dis(code, file=None):
Disassembler().dump_code(code, file=sys.stdout) | null |
186,239 | import argparse
import dis
import marshal
import sys
from types import CodeType
CodeType = type(_f.__code__)
def _get_code(root, item_path=None):
if not item_path:
return root
code = root
for chunk in item_path.split("."):
for subcode in code.co_consts:
if isinstance(subcode, ... | null |
186,243 | import argparse
import collections
import os
import re
import shlex
import subprocess
import sys
from typing import Dict, Iterable, NamedTuple, Sequence
class Stat(NamedTuple):
hits: int
stddev: float
min: float
max: float
Sequence = _alias(collections.abc.Sequence, 1)
Dict = _alias(dict, 2, inst=Fals... | null |
186,244 | import argparse
import collections
import os
import re
import shlex
import subprocess
import sys
from typing import Dict, Iterable, NamedTuple, Sequence
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description="""
Run the given binaries under `perf stat` and print pairwise comp... | null |
186,245 | import argparse
import collections
import os
import re
import shlex
import subprocess
import sys
from typing import Dict, Iterable, NamedTuple, Sequence
class Stat(NamedTuple):
hits: int
stddev: float
min: float
max: float
def measure_binary(
binary: str, repetitions: int, events: Iterable[str], com... | null |
186,246 | import calendar
import email.message
import re
import os
import sys
class Unparseable(Exception):
emparse_list_list = [
'error: (?P<reason>unresolvable): (?P<email>.+)',
('----- The following addresses had permanent fatal errors -----\n',
'(?P<email>[^ \n].*)\n( .*\n)?'),
'remote execution.*\n.*rmail (... | null |
186,247 | import calendar
import email.message
import re
import os
import sys
class Unparseable(Exception):
class ErrorMessage(email.message.Message):
def __init__(self):
def is_warning(self):
def get_errors(self):
def sort_numeric(a, b):
def parsedir(dir, modify):
os.chdir(dir)
pat = re.compile('^[0-9]*$... | null |
186,263 | import os.path
import re
import subprocess
import sys
import sysconfig
IGNORE = {
'__init__',
'__pycache__',
'site-packages',
# Test modules and packages
'__hello__',
'__phello__',
'_ctypes_test',
'_testbuffer',
'_testcapi',
'_testconsole',
'_testimportmultiple',
'_testin... | null |
186,264 | import os.path
import re
import subprocess
import sys
import sysconfig
def write_modules(fp, names):
print("// Auto-generated by Tools/scripts/generate_stdlib_module_names.py.",
file=fp)
print("// List used to create sys.stdlib_module_names.", file=fp)
print(file=fp)
print("static const char*... | null |
186,266 | import argparse
import collections
import os
import re
import subprocess
import sys
from enum import Enum
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument(
"command",
help="Path to runtime_tests binary, optionally with extra arguments to filter which tests run",
... | null |
186,267 | import argparse
import collections
import os
import re
import subprocess
import sys
from enum import Enum
TEST_RUN_RE = re.compile(r"^\[ RUN +\] ([^.]+)\.(.+)$")
ACTUAL_TEXT_RE = re.compile(r'^ Which is: "(.+)\\n"$')
EXPECTED_VAR_RE = re.compile(r"^ ([^ ]+)$")
FINISHED_LINE = "[----------] Global test environment t... | null |
186,268 | import argparse
import collections
import os
import re
import subprocess
import sys
from enum import Enum
TESTS_DIR = os.path.normpath(
os.path.join(os.path.dirname(__file__), "..", "..", "cinderx", "RuntimeTests")
)
def map_suite_to_file_basename(suite_name):
assert map_suite_to_file_basename("CleanCFGTest") == "c... | null |
186,269 | import argparse
import collections
import os
import re
import subprocess
import sys
from enum import Enum
def update_text_test(old_lines, suite_name, failed_tests):
line_iter = iter(old_lines)
new_lines = []
def expect(exp):
line = next(line_iter)
if line != exp:
raise RuntimeE... | null |
186,270 | import argparse
import collections
import os
import re
import subprocess
import sys
from enum import Enum
TESTS_DIR = os.path.normpath(
os.path.join(os.path.dirname(__file__), "..", "..", "cinderx", "RuntimeTests")
)
def write_if_changed(filename, old_lines, new_lines):
if new_lines == old_lines:
return... | null |
186,271 | import argparse
import re
import subprocess
import sys
from enum import Enum
COMMIT_START_RE = re.compile(r"^commit ([a-f0-9]{40})$")
REVISION_RE = re.compile(r" Differential Revision: https.+(D[0-9]+)$")
class State(Enum):
WAIT_FOR_COMMIT = 1
WAIT_FOR_TITLE = 2
WAIT_FOR_REVISION = 3
def find_commits(ar... | null |
186,272 | import argparse
import re
import subprocess
import sys
from enum import Enum
BLAME_LINE_RE = re.compile(r"^([0-9a-f]{40}) ")
def collect_blamed_commits(args, filename, commits):
stdout = subprocess.run(
["git", "blame", "-l", args.end_commit, "--", filename],
check=True,
encoding=sys.stdin.... | null |
186,273 | import argparse
import re
import subprocess
import sys
from enum import Enum
def parse_args():
parser = argparse.ArgumentParser(
description="Generate an abbreviated list of commits from Cinder 3.8, optionally limited to commits that contributed to the current version of a given set of files (as determined... | null |
186,289 | from collections import deque, namedtuple
def namedtuple(typename, field_names, *, rename=False, defaults=None, module=None):
"""Returns a new subclass of tuple with named fields.
>>> Point = namedtuple('Point', ['x', 'y'])
>>> Point.__doc__ # docstring for the new class
'Point(x, y)... | null |
186,310 | import sys
import re
import os
m_import = re.compile('^[ \t]*from[ \t]+([^ \t]+)[ \t]+')
m_from = re.compile('^[ \t]*import[ \t]+([^#]+)')
def process(filename, table):
with open(filename, encoding='utf-8') as fp:
mod = os.path.basename(filename)
if mod[-3:] == '.py':
mod = mod[:-3]
... | null |
186,314 | import re
import os
import sys
import tempfile
PIPE = -1
STDOUT = -2
class Popen:
""" Execute a child program in a new process.
For a complete description of the arguments see the Python documentation.
Arguments:
args: A string, or a sequence of program arguments.
... | null |
186,317 | import argparse
import html
import http.server
import json
import mimetypes
import os
import re
import shlex
import shutil
import socket
import ssl
import subprocess
import tempfile
import urllib.parse
from xml.etree import ElementTree as ET
def annotate_assembly(ir_json, perf_annotations):
events = perf_annotation... | null |
186,318 | import argparse
import html
import http.server
import json
import mimetypes
import os
import re
import shlex
import shutil
import socket
import ssl
import subprocess
import tempfile
import urllib.parse
from xml.etree import ElementTree as ET
def make_server_class(process_args):
if process_args.perf is not None:
... | null |
186,319 | import argparse
import html
import http.server
import json
import mimetypes
import os
import re
import shlex
import shutil
import socket
import ssl
import subprocess
import tempfile
import urllib.parse
from xml.etree import ElementTree as ET
def make_explorer_class(process_args, prod_hostname=None):
runtime = args.... | null |
186,320 | import argparse
import html
import http.server
import json
import mimetypes
import os
import re
import shlex
import shutil
import socket
import ssl
import subprocess
import tempfile
import urllib.parse
from xml.etree import ElementTree as ET
def executable_file(arg):
if not shutil.which(arg, mode=os.F_OK | os.X_OK... | null |
186,321 | import argparse
import html
import http.server
import json
import mimetypes
import os
import re
import shlex
import shutil
import socket
import ssl
import subprocess
import tempfile
import urllib.parse
from xml.etree import ElementTree as ET
def readable_file(arg):
if not shutil.which(arg, mode=os.F_OK):
pa... | null |
186,326 | import os.path
import subprocess
import sys
import sysconfig
IGNORED_EXTENSION = "_ctypes_test"
def check_library(library, dynamic=False):
nm_output = get_exported_symbols(library, dynamic)
smelly_symbols, python_symbols = get_smelly_symbols(nm_output)
if not smelly_symbols:
print(f"OK: no smelly sy... | null |
186,342 | import argparse
import os
import re
import shutil
import subprocess
import sys
from typing import List, NamedTuple
def create_port_branch(args):
def generate_upstream_patches(args):
def parse_args():
args = argparse.ArgumentParser()
subparsers = args.add_subparsers(required=True)
create = subparsers.add_p... | null |
186,343 | import os
import sys
import json
from urllib.request import urlopen
from html.entities import html5
def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
*, cafile=None, capath=None, cadefault=False, context=None):
'''Open the URL url, which can be either a string or a Request object.
... | Download the json file from the url and returns a decoded object. |
186,348 | from functools import partial
from pathlib import Path
import dataclasses
import subprocess
import sysconfig
import argparse
import textwrap
import difflib
import shutil
import sys
import os
import os.path
import io
import re
import csv
class Manifest:
"""Collection of `ABIItem`s forming the stable ABI/limited API.... | Parse the given file (iterable of lines) to a Manifest |
186,349 | from functools import partial
from pathlib import Path
import dataclasses
import subprocess
import sysconfig
import argparse
import textwrap
import difflib
import shutil
import sys
import os
import os.path
import io
import re
import csv
generators = []
The provided code snippet includes necessary dependencies for impl... | Decorates a file generator: function that writes to a file |
186,350 | from functools import partial
from pathlib import Path
import dataclasses
import subprocess
import sysconfig
import argparse
import textwrap
import difflib
import shutil
import sys
import os
import os.path
import io
import re
import csv
class partial:
"""New function with partial application of the given arguments... | Generate/check the source for the Windows stable ABI library |
186,351 | from functools import partial
from pathlib import Path
import dataclasses
import subprocess
import sysconfig
import argparse
import textwrap
import difflib
import shutil
import sys
import os
import os.path
import io
import re
import csv
IFDEF_DOC_NOTES = {
'MS_WINDOWS': 'on Windows',
'HAVE_FORK': 'on platforms ... | Generate/check the stable ABI list for documentation annotations |
186,352 | from functools import partial
from pathlib import Path
import dataclasses
import subprocess
import sysconfig
import argparse
import textwrap
import difflib
import shutil
import sys
import os
import os.path
import io
import re
import csv
The provided code snippet includes necessary dependencies for implementing the `ge... | Generate/check a file with a single generator Return True if successful; False if a comparison failed. |
186,353 | from functools import partial
from pathlib import Path
import dataclasses
import subprocess
import sysconfig
import argparse
import textwrap
import difflib
import shutil
import sys
import os
import os.path
import io
import re
import csv
def _report_unexpected_items(items, msg):
"""If there are any `items`, report t... | Check headers & library using "Unixy" tools (GCC/clang, binutils) |
186,354 | from functools import partial
from pathlib import Path
import dataclasses
import subprocess
import sysconfig
import argparse
import textwrap
import difflib
import shutil
import sys
import os
import os.path
import io
import re
import csv
The provided code snippet includes necessary dependencies for implementing the `ch... | Ensure limited API doesn't contain private names Names prefixed by an underscore are private by definition. |
186,357 | import argparse
import logging
import os
import re
import shlex
import subprocess
import sys
import tempfile
JITLIST_FILENAME = "jitlist.txt"
def write_jitlist(jitlist):
with open(JITLIST_FILENAME, "w") as file:
for func in jitlist:
print(func, file=file)
def read_jitlist(jit_list_file):
wit... | null |
186,358 | import argparse
import logging
import os
import re
import shlex
import subprocess
import sys
import tempfile
def parse_args():
parser = argparse.ArgumentParser(
description="When given a command that fails with the jit enabled (including -X jit as appropriate), bisects to find a minimal jit-list that prese... | null |
186,369 | import sys, re
def generate_typeslots(out=sys.stdout):
out.write("/* Generated by typeslots.py */\n")
res = {}
for line in sys.stdin:
m = re.match("#define Py_([a-z_]+) ([0-9]+)", line)
if not m:
continue
member = m.group(1)
if member.startswith("tp_"):
... | null |
186,370 | import os
import sys
import textwrap
from argparse import ArgumentParser
from contextlib import contextmanager
from pathlib import Path
import asdl
The provided code snippet includes necessary dependencies for implementing the `get_c_type` function. Write a Python function `def get_c_type(name)` to solve the following... | Return a string for the C name of the type. This function special cases the default types provided by asdl. |
186,371 | import os
import sys
import textwrap
from argparse import ArgumentParser
from contextlib import contextmanager
from pathlib import Path
import asdl
TABSIZE = 4
MAX_COL = 80
The provided code snippet includes necessary dependencies for implementing the `reflow_lines` function. Write a Python function `def reflow_lines(... | Reflow the line s indented depth tabs. Return a sequence of lines where no line extends beyond MAX_COL when properly indented. The first line is properly indented based exclusively on depth * TABSIZE. All following lines -- these are the reflowed lines generated by this function -- start at the same column as the first... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.