instance_id
stringlengths
17
47
repo
stringlengths
9
36
image_name
stringlengths
51
78
base_commit
stringlengths
40
40
setup_patch
stringlengths
421
4.69k
patch
stringlengths
421
4.69k
workload
stringlengths
294
1.99k
covering_tests
listlengths
3
399
test_cmd
stringclasses
1 value
rebuild_cmd
stringclasses
1 value
problem_statement
stringlengths
526
939
api
stringlengths
10
95
clean_mean
float64
0.2
7.42
regressed_mean
float64
0.89
55.2
slowdown
float64
3.01
135
source
stringclasses
1 value
Cog-Creators__Red-DiscordBot.perf_0
Cog-Creators/Red-DiscordBot
jyangballin/swesmith.x86_64.cog-creators_1776_red-discordbot.33e0eac7
bc9ec7631756184f7405c0e1c443c8c57eb269d2
diff --git a/redbot/core/utils/__init__.py b/redbot/core/utils/__init__.py index dc3687f..fca043c 100644 --- a/redbot/core/utils/__init__.py +++ b/redbot/core/utils/__init__.py @@ -70,7 +70,11 @@ def deduplicate_iterables(*iterables): were first encountered. """ # dict insertion order is guaranteed to be...
diff --git b/redbot/core/utils/__init__.py a/redbot/core/utils/__init__.py index fca043c..dc3687f 100644 --- b/redbot/core/utils/__init__.py +++ a/redbot/core/utils/__init__.py @@ -70,11 +70,7 @@ def deduplicate_iterables(*iterables): were first encountered. """ # dict insertion order is guaranteed to be...
import random import statistics import timeit from redbot.core.utils import deduplicate_iterables random.seed(20240521) first = [random.randrange(400) for _ in range(120)] second = [random.randrange(400) for _ in range(120)] third = [random.randrange(400) for _ in range(60)] # warm up deduplicate_iterables(first, se...
[ "tests/core/test_utils.py::test_bounded_gather", "tests/core/test_utils.py::test_bounded_gather_iter", "tests/core/test_utils.py::test_deduplicate_iterables", "tests/core/test_utils.py::test_normalize_smartquotes", "tests/core/test_utils.py::test_pagify[@everyone", "tests/core/test_utils.py::test_pagify[I...
python -m pytest -q -rA -p no:cacheprovider
I have a helper that merges a few lists of role/user IDs together while keeping the first-seen order, and I use the utility Red exposes for that in a loop that runs for every guild on every command invocation. With only a couple of hundred IDs coming from two or three lists, each call takes hundreds of microseconds, wh...
redbot.core.utils.deduplicate_iterables
0.95981
16.176191
16.853534
perf-pool-swesmith
Cog-Creators__Red-DiscordBot.perf_3
Cog-Creators/Red-DiscordBot
jyangballin/swesmith.x86_64.cog-creators_1776_red-discordbot.33e0eac7
bc9ec7631756184f7405c0e1c443c8c57eb269d2
diff --git a/redbot/core/utils/chat_formatting.py b/redbot/core/utils/chat_formatting.py index 9a96ae3..bcb72a5 100644 --- a/redbot/core/utils/chat_formatting.py +++ b/redbot/core/utils/chat_formatting.py @@ -486,8 +486,20 @@ def escape(text: str, *, mass_mentions: bool = False, formatting: bool = False) """ ...
diff --git b/redbot/core/utils/chat_formatting.py a/redbot/core/utils/chat_formatting.py index bcb72a5..9a96ae3 100644 --- b/redbot/core/utils/chat_formatting.py +++ a/redbot/core/utils/chat_formatting.py @@ -486,20 +486,8 @@ def escape(text: str, *, mass_mentions: bool = False, formatting: bool = False) """ ...
import statistics import timeit from redbot.core.utils.chat_formatting import escape text = "Hello @everyone and @here, please read this notice " + "content " * 6 # warm up escape(text, mass_mentions=True) N = 800000 results = timeit.repeat(lambda: escape(text, mass_mentions=True), number=N, repeat=5) print(f"Mean:...
[ "tests/core/test_utils.py::test_bounded_gather", "tests/core/test_utils.py::test_bounded_gather_iter", "tests/core/test_utils.py::test_deduplicate_iterables", "tests/core/test_utils.py::test_normalize_smartquotes", "tests/core/test_utils.py::test_pagify[@everyone", "tests/core/test_utils.py::test_pagify[I...
python -m pytest -q -rA -p no:cacheprovider
I sanitize user-provided strings with Red's escape helper (mass mentions enabled) before echoing them back; my cog does this for every row of a leaderboard, so it happens hundreds of thousands of times per refresh. Each call on a short ~100 character line now costs tens of microseconds instead of being basically free, ...
redbot.core.utils.chat_formatting.escape
0.576705
25.965209
45.023417
perf-pool-swesmith
Instagram__MonkeyType.perf_0
Instagram/MonkeyType
jyangballin/swesmith.x86_64.instagram_1776_monkeytype.70c3acf6
810d9de4f99bb45a9b404a943bb2c9e54d578b16
diff --git a/monkeytype/typing.py b/monkeytype/typing.py index 507732b..45333a6 100644 --- a/monkeytype/typing.py +++ b/monkeytype/typing.py @@ -553,13 +553,15 @@ class RewriteMostSpecificCommonBase(TypeRewriter): """ klasses = union.__args__ - all_bases = [] - - for klass in klasses: ...
diff --git b/monkeytype/typing.py a/monkeytype/typing.py index 45333a6..507732b 100644 --- b/monkeytype/typing.py +++ a/monkeytype/typing.py @@ -553,15 +553,13 @@ class RewriteMostSpecificCommonBase(TypeRewriter): """ klasses = union.__args__ - common_bases = self._compute_bases(klasses[0]) -...
import timeit from typing import Union from monkeytype.typing import RewriteMostSpecificCommonBase def build_leaves(common_depth=40, branches=20, leaf_depth=10): cls = type("Root", (object,), {}) for i in range(common_depth): cls = type("Mid%d" % i, (cls,), {}) leaves = [] for j in range(bran...
[ "tests/test_typing.py::TestGetType::test_builtin_types[1-int]", "tests/test_typing.py::TestGetType::test_builtin_types[1.1-float]", "tests/test_typing.py::TestGetType::test_builtin_types[<lambda>-Callable]", "tests/test_typing.py::TestGetType::test_builtin_types[Dummy-Type]", "tests/test_typing.py::TestGetT...
python -m pytest -q -rA -p no:cacheprovider
I'm using the "most specific common base" union rewriting on unions of model classes coming from a fairly deep class hierarchy (our ORM base chain is ~50 classes deep and I typically have 15-25 sibling subclasses in a single union). Rewriting a single union takes close to a millisecond, and since this happens for a lot...
monkeytype.typing.RewriteMostSpecificCommonBase.rewrite
0.510707
5.243981
10.268086
perf-pool-swesmith
Instagram__MonkeyType.perf_1
Instagram/MonkeyType
jyangballin/swesmith.x86_64.instagram_1776_monkeytype.70c3acf6
810d9de4f99bb45a9b404a943bb2c9e54d578b16
diff --git a/monkeytype/tracing.py b/monkeytype/tracing.py index 1360d08..18b865e 100644 --- a/monkeytype/tracing.py +++ b/monkeytype/tracing.py @@ -218,9 +218,9 @@ class CallTracer: def _get_func(self, frame: FrameType) -> Optional[Callable[..., Any]]: code = frame.f_code - if code not in self.c...
diff --git b/monkeytype/tracing.py a/monkeytype/tracing.py index 18b865e..1360d08 100644 --- b/monkeytype/tracing.py +++ a/monkeytype/tracing.py @@ -218,9 +218,9 @@ class CallTracer: def _get_func(self, frame: FrameType) -> Optional[Callable[..., Any]]: code = frame.f_code - func = get_func(frame...
import timeit from monkeytype.tracing import CallTraceLogger, trace_calls class NullLogger(CallTraceLogger): def log(self, trace): pass def make_obj(depth=60): def target(self, x): return x + 1 cls = type("C0", (object,), {"target": target}) for i in range(1, depth): cls = ...
[ "tests/test_tracing.py::TestGetFunc::test_get_func[frame0-a_static_method]", "tests/test_tracing.py::TestGetFunc::test_get_func[frame1-a_class_method]", "tests/test_tracing.py::TestGetFunc::test_get_func[frame2-an_instance_method]", "tests/test_tracing.py::TestGetFunc::test_get_func[frame3-a_module_function]"...
python -m pytest -q -rA -p no:cacheprovider
Running my test suite under MonkeyType tracing is much slower than I'd expect. The hot spot is a method defined on a base class of a fairly deep class hierarchy (about 60 levels of single inheritance), which gets called hundreds of thousands of times. Tracing the same method over and over seems to redo the same expensi...
monkeytype.tracing.CallTracer._get_func
0.538628
9.124814
16.940846
perf-pool-swesmith
Instagram__MonkeyType.perf_2
Instagram/MonkeyType
jyangballin/swesmith.x86_64.instagram_1776_monkeytype.70c3acf6
810d9de4f99bb45a9b404a943bb2c9e54d578b16
diff --git a/monkeytype/typing.py b/monkeytype/typing.py index 507732b..a4a8bfc 100644 --- a/monkeytype/typing.py +++ b/monkeytype/typing.py @@ -342,7 +342,14 @@ class GenericTypeRewriter(Generic[T], ABC): typname = name_of_generic(typ) else: typname = getattr(typ, "__name__", None) -...
diff --git b/monkeytype/typing.py a/monkeytype/typing.py index a4a8bfc..507732b 100644 --- b/monkeytype/typing.py +++ a/monkeytype/typing.py @@ -342,14 +342,7 @@ class GenericTypeRewriter(Generic[T], ABC): typname = name_of_generic(typ) else: typname = getattr(typ, "__name__", None) -...
import timeit from typing import Dict, List, Optional, Set, Tuple, Union from monkeytype.stubs import render_annotation anno = Dict[ str, List[ Tuple[ int, Optional[str], Dict[str, Set[int]], Union[int, str, float], List[Tuple[str, Optional[i...
[ "tests/test_stubs.py::TestAttributeStub::test_simple_attribute[stub0-", "tests/test_stubs.py::TestAttributeStub::test_simple_attribute[stub1-", "tests/test_stubs.py::TestBuildModuleStubs::test_build_module_stubs", "tests/test_stubs.py::TestBuildModuleStubs::test_build_module_stubs_typed_dict_parameter", "te...
python -m pytest -q -rA -p no:cacheprovider
Rendering annotations for stubs got noticeably sluggish for us. We generate stubs for a module with a lot of functions whose arguments have moderately nested generic annotations (dicts of lists of tuples containing unions and optionals), and rendering a single annotation costs hundreds of microseconds, which adds up to...
monkeytype.typing.GenericTypeRewriter.rewrite
0.33485
2.48583
7.423722
perf-pool-swesmith
Instagram__MonkeyType.perf_3
Instagram/MonkeyType
jyangballin/swesmith.x86_64.instagram_1776_monkeytype.70c3acf6
810d9de4f99bb45a9b404a943bb2c9e54d578b16
diff --git a/monkeytype/cli.py b/monkeytype/cli.py index 990079d..da570e1 100644 --- a/monkeytype/cli.py +++ b/monkeytype/cli.py @@ -102,8 +102,12 @@ def get_monkeytype_config(path: str) -> Config: def display_sample_count(traces: List[CallTrace], stderr: IO[str]) -> None: """Print to stderr the number of trace...
diff --git b/monkeytype/cli.py a/monkeytype/cli.py index da570e1..990079d 100644 --- b/monkeytype/cli.py +++ a/monkeytype/cli.py @@ -102,12 +102,8 @@ def get_monkeytype_config(path: str) -> Config: def display_sample_count(traces: List[CallTrace], stderr: IO[str]) -> None: """Print to stderr the number of trace...
import io import timeit from monkeytype.cli import display_sample_count from monkeytype.tracing import CallTrace def f0(a): return a def f1(a): return a def f2(a): return a def f3(a): return a def f4(a): return a def f5(a): return a funcs = [f0, f1, f2, f3, f4, f5] traces = [CallT...
[ "tests/test_cli.py::test_apply_stub_file_with_spaces", "tests/test_cli.py::test_apply_stub_init", "tests/test_cli.py::test_apply_stub_using_libcst", "tests/test_cli.py::test_apply_stub_using_libcst__confine_new_imports_in_type_checking_block", "tests/test_cli.py::test_apply_stub_using_libcst__exception", ...
python -m pytest -q -rA -p no:cacheprovider
When I run `monkeytype stub --sample-count` (or `apply --sample-count`) on a module with a few thousand stored traces, printing the per-function sample counts takes a surprisingly long time — several seconds of the CLI run are spent just producing those few lines of output. The number of lines printed is tiny (one per ...
monkeytype.cli.display_sample_count
1.324241
7.952509
6.005333
perf-pool-swesmith
Knio__dominate.perf_0
Knio/dominate
jyangballin/swesmith.x86_64.knio_1776_dominate.9082227e
e8fb15dc30d653ed6fc46487a47add94cf805e1c
diff --git a/dominate/util.py b/dominate/util.py index 1d730b3..833e010 100644 --- a/dominate/util.py +++ b/dominate/util.py @@ -61,12 +61,16 @@ def escape(data, quote=True): # stolen from std lib cgi This is used to escape content that appears in the body of an HTML document ''' - data = data.replace("&", "&...
diff --git b/dominate/util.py a/dominate/util.py index 833e010..1d730b3 100644 --- b/dominate/util.py +++ a/dominate/util.py @@ -61,16 +61,12 @@ def escape(data, quote=True): # stolen from std lib cgi This is used to escape content that appears in the body of an HTML document ''' - # Table driven translation:...
import random import statistics import string import timeit from dominate.util import escape random.seed(1234) alphabet = string.ascii_letters + ' .,;:' + '<>&"' snippets = [''.join(random.choice(alphabet) for _ in range(400)) for _ in range(2000)] def run(): total = 0 for snippet in s...
[ "tests/test_dominate.py::test_version", "tests/test_html.py::test_add", "tests/test_html.py::test_arguments", "tests/test_html.py::test_attribute_dashes", "tests/test_html.py::test_attribute_none", "tests/test_html.py::test_attributes", "tests/test_html.py::test_boolean_attributes", "tests/test_html.p...
python -m pytest -q -rA -p no:cacheprovider
We use dominate to build pages out of user supplied text, so every snippet gets run through dominate's html escaping helper before it goes into the document. On a page with a couple of thousand paragraphs of a few hundred characters each, the escaping alone now takes noticeably longer than everything else we do, and bu...
dominate.util.escape
1.026926
13.999767
13.632699
perf-pool-swesmith
Knio__dominate.perf_1
Knio/dominate
jyangballin/swesmith.x86_64.knio_1776_dominate.9082227e
e8fb15dc30d653ed6fc46487a47add94cf805e1c
diff --git a/dominate/util.py b/dominate/util.py index 1d730b3..1698e01 100644 --- a/dominate/util.py +++ b/dominate/util.py @@ -116,8 +116,19 @@ def url_escape(data): def url_unescape(data): - return re.sub('%([0-9a-fA-F]{2})', - lambda m: unichr(int(m.group(1), 16)), data) + hex_digits = '0123456789abcdefAB...
diff --git b/dominate/util.py a/dominate/util.py index 1698e01..1d730b3 100644 --- b/dominate/util.py +++ a/dominate/util.py @@ -116,19 +116,8 @@ def url_escape(data): def url_unescape(data): - hex_digits = '0123456789abcdefABCDEF' - result = [] - i = 0 - while i < len(data): - c = data[i] - if c == '%' ...
import statistics import timeit from dominate.util import url_unescape paths = [] for i in range(1000): parts = ['segment%d-%d' % (i % 17, j) for j in range(10)] paths.append('/'.join(parts) + '?q=hello%20world&page=%2F' + str(i) + '&tag=caf%C3%A9') def run(): total = 0 for path in ...
[ "tests/test_utils.py::test_container", "tests/test_utils.py::test_context", "tests/test_utils.py::test_include", "tests/test_utils.py::test_system", "tests/test_utils.py::test_unescape", "tests/test_utils.py::test_url" ]
python -m pytest -q -rA -p no:cacheprovider
I'm using dominate's url unescaping helper to decode a batch of request paths/query strings (about a thousand strings of ~130 characters each, with only a handful of percent escapes in each). Decoding the batch takes tens of milliseconds, which is way more than I expected for such short strings, and it clearly scales w...
dominate.util.url_unescape
0.670992
5.819844
8.673495
perf-pool-swesmith
Knio__dominate.perf_3
Knio/dominate
jyangballin/swesmith.x86_64.knio_1776_dominate.9082227e
e8fb15dc30d653ed6fc46487a47add94cf805e1c
diff --git a/dominate/dom_tag.py b/dominate/dom_tag.py index 44ca8ba..3bf5422 100644 --- a/dominate/dom_tag.py +++ b/dominate/dom_tag.py @@ -216,13 +216,15 @@ class dom_tag(object): if isinstance(obj, basestring): obj = util.escape(obj) - self.children.append(obj) + # rebind children to ...
diff --git b/dominate/dom_tag.py a/dominate/dom_tag.py index 3bf5422..44ca8ba 100644 --- b/dominate/dom_tag.py +++ a/dominate/dom_tag.py @@ -216,15 +216,13 @@ class dom_tag(object): if isinstance(obj, basestring): obj = util.escape(obj) - # rebind children to a new list so that callers holding ...
import statistics import timeit from dominate import tags lines = ['%05d some log line with content here\n' % i for i in range(12000)] def build(): block = tags.pre() for line in lines: block.add(line) return block build() # warm up times = timeit.repeat(build, number=25, repeat=5) print("M...
[ "tests/test_document.py::test_attributes", "tests/test_document.py::test_bare_decorator", "tests/test_document.py::test_containers", "tests/test_document.py::test_decorator", "tests/test_document.py::test_doc", "tests/test_document.py::test_repr", "tests/test_document.py::test_title", "tests/test_dom_...
python -m pytest -q -rA -p no:cacheprovider
I dump log files into a page by creating a &lt;pre&gt; tag and appending each line to it in a loop. With around 12,000 lines this takes close to a third of a second just to assemble the tag (before any rendering happens), and the cost clearly grows quadratically: 6,000 lines take about a quarter of the time of 12,000. ...
dominate.dom_tag.dom_tag.add
0.374804
7.083057
18.898048
perf-pool-swesmith
Mimino666__langdetect.perf_0
Mimino666/langdetect
jyangballin/swesmith.x86_64.mimino666_1776_langdetect.a1598f1a
fdd1c1b5222aa8a06136867324870e27a3c02d01
diff --git a/langdetect/utils/unicode_block.py b/langdetect/utils/unicode_block.py index f074189..eabd1f9 100644 --- a/langdetect/utils/unicode_block.py +++ b/langdetect/utils/unicode_block.py @@ -452,14 +452,9 @@ def unicode_block(ch): # special case basic latin if cp <= 0x7F: return UNICODE_BASIC_L...
diff --git b/langdetect/utils/unicode_block.py a/langdetect/utils/unicode_block.py index eabd1f9..f074189 100644 --- b/langdetect/utils/unicode_block.py +++ a/langdetect/utils/unicode_block.py @@ -452,9 +452,14 @@ def unicode_block(ch): # special case basic latin if cp <= 0x7F: return UNICODE_BASIC_L...
import random import statistics import timeit from langdetect.utils.unicode_block import unicode_block random.seed(20240101) RANGES = [ (0x4E00, 0x9FFF), # CJK Unified Ideographs (0x3040, 0x309F), # Hiragana (0x30A0, 0x30FF), # Katakana (0xAC00, 0xD7AF), # Hangul Syllables (0x0400, 0x04FF...
[ "langdetect/tests/test_detector.py::DetectorTest::test_detector1", "langdetect/tests/test_detector.py::DetectorTest::test_detector2", "langdetect/tests/test_detector.py::DetectorTest::test_detector3", "langdetect/tests/test_detector.py::DetectorTest::test_detector4", "langdetect/tests/test_detector.py::Dete...
python -m pytest -q -rA -p no:cacheprovider
I'm running language detection over a large batch of non-Latin documents (Chinese, Japanese, Korean, Cyrillic, Thai, Devanagari) and the per-character character-classification step has become the bottleneck. Classifying a few thousand non-ASCII characters takes several milliseconds, which adds up to minutes over my cor...
langdetect.utils.unicode_block.unicode_block
0.721631
2.273396
3.150359
perf-pool-swesmith
Mimino666__langdetect.perf_1
Mimino666/langdetect
jyangballin/swesmith.x86_64.mimino666_1776_langdetect.a1598f1a
fdd1c1b5222aa8a06136867324870e27a3c02d01
diff --git a/langdetect/utils/ngram.py b/langdetect/utils/ngram.py index ee82e38..75c1e78 100644 --- a/langdetect/utils/ngram.py +++ b/langdetect/utils/ngram.py @@ -91,7 +91,13 @@ class NGram(object): elif block in (UNICODE_BOPOMOFO, UNICODE_BOPOMOFO_EXTENDED): ch = six.u('\u3105') elif b...
diff --git b/langdetect/utils/ngram.py a/langdetect/utils/ngram.py index 75c1e78..ee82e38 100644 --- b/langdetect/utils/ngram.py +++ a/langdetect/utils/ngram.py @@ -91,13 +91,7 @@ class NGram(object): elif block in (UNICODE_BOPOMOFO, UNICODE_BOPOMOFO_EXTENDED): ch = six.u('\u3105') elif b...
import random import statistics import timeit from langdetect.utils.ngram import NGram random.seed(4242) TEXT = ''.join(chr(random.randint(0x4E00, 0x9FFF)) for _ in range(2000)) def run(): for ch in TEXT: NGram.normalize(ch) run() # warm up times = timeit.repeat(run, number=200, repeat=5) print('Me...
[ "langdetect/tests/test_detector.py::DetectorTest::test_detector1", "langdetect/tests/test_detector.py::DetectorTest::test_detector2", "langdetect/tests/test_detector.py::DetectorTest::test_detector3", "langdetect/tests/test_detector.py::DetectorTest::test_detector4", "langdetect/tests/test_detector.py::Dete...
python -m pytest -q -rA -p no:cacheprovider
Normalizing Chinese/Japanese text before feature extraction is far slower than I expected. On a 2000-character Chinese document, normalizing character by character takes several tens of milliseconds; the same amount of Cyrillic or Latin text is roughly an order of magnitude faster. Since CJK is a big chunk of my corpus...
langdetect.utils.ngram.NGram.normalize
0.742901
4.386085
5.904
perf-pool-swesmith
Mimino666__langdetect.perf_2
Mimino666/langdetect
jyangballin/swesmith.x86_64.mimino666_1776_langdetect.a1598f1a
fdd1c1b5222aa8a06136867324870e27a3c02d01
diff --git a/langdetect/utils/ngram.py b/langdetect/utils/ngram.py index ee82e38..1c908f1 100644 --- a/langdetect/utils/ngram.py +++ b/langdetect/utils/ngram.py @@ -101,11 +101,20 @@ class NGram(object): '''Normalizer for Vietnamese. Normalize Alphabet + Diacritical Mark(U+03xx) into U+1Exx. ...
diff --git b/langdetect/utils/ngram.py a/langdetect/utils/ngram.py index 1c908f1..ee82e38 100644 --- b/langdetect/utils/ngram.py +++ a/langdetect/utils/ngram.py @@ -101,20 +101,11 @@ class NGram(object): '''Normalizer for Vietnamese. Normalize Alphabet + Diacritical Mark(U+03xx) into U+1Exx. ...
import random import statistics import timeit from langdetect.utils.ngram import NGram random.seed(31337) LETTERS = 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ' chars = [] while len(chars) < 20000: if random.random() < 0.02: chars.append(random.choice(NGram.TO_NORMALIZE_VI_CHARS)) ...
[ "langdetect/tests/test_detector.py::DetectorTest::test_detector1", "langdetect/tests/test_detector.py::DetectorTest::test_detector2", "langdetect/tests/test_detector.py::DetectorTest::test_detector3", "langdetect/tests/test_detector.py::DetectorTest::test_detector4", "langdetect/tests/test_detector.py::Dete...
python -m pytest -q -rA -p no:cacheprovider
I feed fairly long documents (20-50 KB of text) into the detector and noticed that a big fraction of the total time is spent in the Vietnamese diacritic normalization pass that runs on every appended text, even for documents that contain almost no combining marks at all. For a 20k-character document with only a couple ...
langdetect.utils.ngram.NGram.normalize_vi
0.692071
6.931504
10.015592
perf-pool-swesmith
Mimino666__langdetect.perf_3
Mimino666/langdetect
jyangballin/swesmith.x86_64.mimino666_1776_langdetect.a1598f1a
fdd1c1b5222aa8a06136867324870e27a3c02d01
diff --git a/langdetect/detector_factory.py b/langdetect/detector_factory.py index e026161..4dc2b58 100644 --- a/langdetect/detector_factory.py +++ b/langdetect/detector_factory.py @@ -83,9 +83,11 @@ class DetectorFactory(object): raise LangDetectException(ErrorCode.DuplicateLangError, 'Duplicate the same ...
diff --git b/langdetect/detector_factory.py a/langdetect/detector_factory.py index 4dc2b58..e026161 100644 --- b/langdetect/detector_factory.py +++ a/langdetect/detector_factory.py @@ -83,11 +83,9 @@ class DetectorFactory(object): raise LangDetectException(ErrorCode.DuplicateLangError, 'Duplicate the same ...
import random import statistics import timeit from langdetect.detector_factory import DetectorFactory from langdetect.utils.lang_profile import LangProfile random.seed(99) ALPHABET = 'abcdefghijklmnopqrstuvwxyz' words = set() while len(words) < 800: n = random.randint(1, 3) words.add(''.join(random.choice(AL...
[ "langdetect/tests/test_detector.py::DetectorTest::test_detector1", "langdetect/tests/test_detector.py::DetectorTest::test_detector2", "langdetect/tests/test_detector.py::DetectorTest::test_detector3", "langdetect/tests/test_detector.py::DetectorTest::test_detector4", "langdetect/tests/test_detector.py::Dete...
python -m pytest -q -rA -p no:cacheprovider
Registering language profiles into a factory has become surprisingly expensive for me. I build my own profiles (a few hundred to a few thousand n-grams each) and add several of them to a factory at startup; adding three profiles with ~800 n-grams each takes tens of milliseconds, and the cost clearly grows super-linearl...
langdetect.detector_factory.DetectorFactory.add_profile
0.365655
5.498859
15.038387
perf-pool-swesmith
google__textfsm.perf_1
google/textfsm
jyangballin/swesmith.x86_64.google_1776_textfsm.c31b6007
b8d48ec31de6fcc701b3b1b2f5952831d90a8b09
diff --git a/textfsm/texttable.py b/textfsm/texttable.py index 5af6be6..04e839c 100755 --- a/textfsm/texttable.py +++ b/textfsm/texttable.py @@ -86,8 +86,13 @@ class Row(dict): ret.append(self[col]) return ret + # Map the column names to their offset in the row. + index = {} + for i, key in e...
diff --git b/textfsm/texttable.py a/textfsm/texttable.py index 04e839c..5af6be6 100755 --- b/textfsm/texttable.py +++ a/textfsm/texttable.py @@ -86,13 +86,8 @@ class Row(dict): ret.append(self[col]) return ret - # Map the column names to their offset in the row. - index = {} - for i, key in e...
import io import random import timeit from textfsm import texttable random.seed(1) COLS = 60 ROWS = 120 lines = [','.join('col%d' % i for i in range(COLS))] for r in range(ROWS): lines.append( ','.join('v%d_%d' % (r, random.randint(1000, 9999)) for _ in range(COLS)) ) csv_data = '\n'.join(lines) + '\n' t...
[ "tests/texttable_test.py::UnitTestRow::testHeader", "tests/texttable_test.py::UnitTestRow::testIndex", "tests/texttable_test.py::UnitTestRow::testRowBasicMethods", "tests/texttable_test.py::UnitTestRow::testRowPublicMethods", "tests/texttable_test.py::UnitTestRow::testSetValues", "tests/texttable_test.py:...
python -m pytest -q -rA -p no:cacheprovider
I have a wide table (about 60 columns, a few hundred rows) built from CSV and I walk over every row pulling out fields by their column name, e.g. `row['ifname']`. A single full pass over the table costs tens of milliseconds, which feels wrong for what should just be a name-to-offset lookup per field; fetching a value b...
textfsm.texttable.Row.__getitem__
0.24828
3.322589
13.382446
perf-pool-swesmith
erikrose__parsimonious.perf_0
erikrose/parsimonious
jyangballin/swesmith.x86_64.erikrose_1776_parsimonious.0d3f5f93
4c817331415d1f5f78e2710ca314be1a62f1ad15
diff --git a/parsimonious/expressions.py b/parsimonious/expressions.py index a1cf40b..622a5c9 100644 --- a/parsimonious/expressions.py +++ b/parsimonious/expressions.py @@ -440,7 +440,8 @@ class Quantifier(Compound): length = node.end - node.start if len(children) >= self.min and length == 0: ...
diff --git b/parsimonious/expressions.py a/parsimonious/expressions.py index 622a5c9..a1cf40b 100644 --- b/parsimonious/expressions.py +++ a/parsimonious/expressions.py @@ -440,8 +440,7 @@ class Quantifier(Compound): length = node.end - node.start if len(children) >= self.min and length == 0: ...
import timeit from parsimonious.grammar import Grammar grammar = Grammar(r''' doc = entry* entry = key "=" value ws key = "alpha" / "beta" / "gamma" / "delta" value = ~"[0-9a-f]{16}" ws = ~"[ \n]*" ''') keys = ['alpha', 'beta', 'gamma', 'delta'] parts = [] for i in range(4000): parts.appen...
[ "parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_call_vs_inline", "parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_lists_vs_dicts", "parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_startswith_vs_regex", "parsimonious/tests/test_expressions.py::ErrorReportingTests::test_favo...
python -m pytest -q -rA -p no:cacheprovider
I use parsimonious to parse machine-generated config dumps: a grammar whose top level is basically `doc = entry*` over a few thousand `key=value` lines. For a small file (a few hundred entries) parsing is instant, but as the file grows the parse time grows much faster than the file does: 4000 entries takes well over a ...
parsimonious.grammar.Grammar.parse
0.258475
3.915094
15.146906
perf-pool-swesmith
erikrose__parsimonious.perf_2
erikrose/parsimonious
jyangballin/swesmith.x86_64.erikrose_1776_parsimonious.0d3f5f93
4c817331415d1f5f78e2710ca314be1a62f1ad15
diff --git a/parsimonious/expressions.py b/parsimonious/expressions.py index a1cf40b..b5c0224 100644 --- a/parsimonious/expressions.py +++ b/parsimonious/expressions.py @@ -260,7 +260,8 @@ class Literal(Expression): self.identity_tuple = (name, literal) def _uncached_match(self, text, pos, cache, error)...
diff --git b/parsimonious/expressions.py a/parsimonious/expressions.py index b5c0224..a1cf40b 100644 --- b/parsimonious/expressions.py +++ a/parsimonious/expressions.py @@ -260,8 +260,7 @@ class Literal(Expression): self.identity_tuple = (name, literal) def _uncached_match(self, text, pos, cache, error)...
import timeit from parsimonious.grammar import Grammar grammar = Grammar(r''' doc = entry* entry = key "=" value ws key = "alpha" / "beta" / "gamma" / "delta" value = ~"[0-9a-f]{16}" ws = ~"[ \n]*" ''') keys = ['alpha', 'beta', 'gamma', 'delta'] parts = [] for i in range(25000): parts.appe...
[ "parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_call_vs_inline", "parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_lists_vs_dicts", "parsimonious/tests/test_benchmarks.py::TestBenchmarks::test_startswith_vs_regex", "parsimonious/tests/test_expressions.py::ErrorReportingTests::test_favo...
python -m pytest -q -rA -p no:cacheprovider
I parse largish key/value dumps (a few hundred kilobytes, ~25k records) with a grammar that uses a handful of plain string alternatives for the record keys plus a couple of regexes. Parsing takes multiple seconds, and worse, it gets disproportionately slower as the file grows: doubling the file size roughly quadruples ...
parsimonious.grammar.Grammar.parse
0.289136
1.399375
4.839845
perf-pool-swesmith
erikrose__parsimonious.perf_3
erikrose/parsimonious
jyangballin/swesmith.x86_64.erikrose_1776_parsimonious.0d3f5f93
4c817331415d1f5f78e2710ca314be1a62f1ad15
diff --git a/parsimonious/nodes.py b/parsimonious/nodes.py index 7839097..b7dac43 100644 --- a/parsimonious/nodes.py +++ b/parsimonious/nodes.py @@ -75,14 +75,14 @@ class Node(object): # them all. Whoops. def indent(text): return '\n'.join((' ' + line) for line in text.splitlines()) - ...
diff --git b/parsimonious/nodes.py a/parsimonious/nodes.py index b7dac43..7839097 100644 --- b/parsimonious/nodes.py +++ a/parsimonious/nodes.py @@ -75,14 +75,14 @@ class Node(object): # them all. Whoops. def indent(text): return '\n'.join((' ' + line) for line in text.splitlines()) - ...
import timeit from parsimonious.grammar import Grammar grammar = Grammar(r''' doc = word* word = letters ws letters = ~"[a-z]+" ws = ~"[ \n]*" ''') vocabulary = ['alpha', 'bravo', 'charlie', 'delta', 'echo', 'foxtrot'] parts = [] for i in range(10000): parts.append(vocabulary[i % len(vocabular...
[ "parsimonious/tests/test_grammar.py::BootstrappingGrammarTests::test_quantifier", "parsimonious/tests/test_grammar.py::BootstrappingGrammarTests::test_regex", "parsimonious/tests/test_grammar.py::BootstrappingGrammarTests::test_spaceless_literal", "parsimonious/tests/test_grammar.py::BootstrappingGrammarTests...
python -m pytest -q -rA -p no:cacheprovider
When debugging a grammar I dump the parse tree with `str(node)` (and I hit the same thing indirectly when a visitor raises and the error message embeds the tree). For a tree whose root has ~10k children this takes well over a second, and it gets much worse than linearly as I add more input: 5k children is roughly a qua...
parsimonious.nodes.Node.prettily
0.275571
3.242508
11.7665
perf-pool-swesmith
python-trio__trio.perf_0
python-trio/trio
jyangballin/swesmith.x86_64.python-trio_1776_trio.cfbbe2c1
1d2401c79fa90d21ea9745a8f717046d1ff79514
diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py index bfb38f4..c816513 100644 --- a/src/trio/_core/_run.py +++ b/src/trio/_core/_run.py @@ -283,7 +283,9 @@ class Deadlines: def expire(self, now: float) -> bool: did_something = False - while self._heap and self._heap[0][0] <= now: + ...
diff --git b/src/trio/_core/_run.py a/src/trio/_core/_run.py index c816513..bfb38f4 100644 --- b/src/trio/_core/_run.py +++ a/src/trio/_core/_run.py @@ -283,9 +283,7 @@ class Deadlines: def expire(self, now: float) -> bool: did_something = False - # Look at the earliest deadline that is still reg...
import statistics import timeit from contextlib import ExitStack import trio NUM_SCOPES = 4000 NUM_CHECKPOINTS = 4000 async def main() -> None: now = trio.current_time() with ExitStack() as stack: for i in range(NUM_SCOPES): stack.enter_context(trio.move_on_at(now + 1000.0 + i)) ...
[ "src/trio/_core/_tests/test_run.py::test_CancelScope_subclass", "src/trio/_core/_tests/test_run.py::test_Cancelled_init", "src/trio/_core/_tests/test_run.py::test_Cancelled_str", "src/trio/_core/_tests/test_run.py::test_Cancelled_subclass", "src/trio/_core/_tests/test_run.py::test_Nursery_init", "src/trio...
python -m pytest -q -rA -p no:cacheprovider
I have a server-ish workload where each in-flight request holds its own timeout scope, so at any moment there are a few thousand live `trio.move_on_at`/`fail_after` scopes with far-future deadlines. Once the number of outstanding scopes grows into the thousands, plain `await trio.lowlevel.checkpoint()` (and therefore e...
trio.lowlevel.checkpoint (deadline expiry bookkeeping in the run loop)
0.502963
4.42157
8.79105
perf-pool-swesmith
python-trio__trio.perf_3
python-trio/trio
jyangballin/swesmith.x86_64.python-trio_1776_trio.cfbbe2c1
1d2401c79fa90d21ea9745a8f717046d1ff79514
diff --git a/src/trio/_sync.py b/src/trio/_sync.py index ca37392..b56c4e2 100644 --- a/src/trio/_sync.py +++ b/src/trio/_sync.py @@ -302,7 +302,9 @@ class CapacityLimiter(AsyncContextManagerMixin): tokens. """ - if borrower in self._borrowers: + # Make sure this borrower isn't al...
diff --git b/src/trio/_sync.py a/src/trio/_sync.py index b56c4e2..ca37392 100644 --- b/src/trio/_sync.py +++ a/src/trio/_sync.py @@ -302,9 +302,7 @@ class CapacityLimiter(AsyncContextManagerMixin): tokens. """ - # Make sure this borrower isn't already holding a token; compare - #...
import statistics import timeit import trio SIZE = 1000 async def main() -> None: limiter = trio.CapacityLimiter(SIZE) borrowers = [object() for _ in range(SIZE)] for b in borrowers: limiter.acquire_on_behalf_of_nowait(b) for b in borrowers: limiter.release_on_behalf_of(b) def run(...
[ "src/trio/_tests/test_sync.py::test_CapacityLimiter", "src/trio/_tests/test_sync.py::test_CapacityLimiter_change_total_tokens", "src/trio/_tests/test_sync.py::test_CapacityLimiter_inf", "src/trio/_tests/test_sync.py::test_CapacityLimiter_memleak_548", "src/trio/_tests/test_sync.py::test_Condition", "src/t...
python -m pytest -q -rA -p no:cacheprovider
I'm using a `trio.CapacityLimiter` with a large token count (about a thousand) and handing out tokens on behalf of my own connection objects via `acquire_on_behalf_of_nowait()`. As the number of tokens currently held grows, each additional acquire gets slower and slower — filling the limiter to capacity takes tens of m...
trio.CapacityLimiter.acquire_on_behalf_of_nowait
0.282868
4.100634
14.496612
perf-pool-swesmith
gawel__pyquery.perf_2
gawel/pyquery
jyangballin/swesmith.x86_64.gawel_1776_pyquery.811cd048
610572bd9a288f3f8967a43bf0d3df257a6ee3be
diff --git a/pyquery/pyquery.py b/pyquery/pyquery.py index 5b05681..a96a4c7 100644 --- a/pyquery/pyquery.py +++ b/pyquery/pyquery.py @@ -608,9 +608,9 @@ class PyQuery(list): return self._filter_only(selector, self) else: elements = [] - args = getargspec(callback) ...
diff --git b/pyquery/pyquery.py a/pyquery/pyquery.py index a96a4c7..5b05681 100644 --- b/pyquery/pyquery.py +++ a/pyquery/pyquery.py @@ -608,9 +608,9 @@ class PyQuery(list): return self._filter_only(selector, self) else: elements = [] + args = getargspec(callback) ...
import timeit import statistics from pyquery import PyQuery parts = [] for i in range(3000): parts.append('<p>item %d</p>' % i) doc = PyQuery('<div>' + ''.join(parts) + '</div>') sel = doc('p') predicate = lambda i: i % 3 == 0 # noqa: E731 # warm up sel.filter(predicate) res = timeit.repeat(lambda: sel.filter(...
[ "tests/test_pyquery.py::TestAjax::test_serialize", "tests/test_pyquery.py::TestAjax::test_serialize_array", "tests/test_pyquery.py::TestAjax::test_serialize_dict", "tests/test_pyquery.py::TestAjax::test_serialize_pairs_filter_controls", "tests/test_pyquery.py::TestAjax::test_serialize_pairs_form_controls", ...
python -m pytest -q -rA -p no:cacheprovider
I filter selections with a Python predicate, e.g. `doc('p').filter(lambda i: i % 3 == 0)`, on selections of a few thousand elements. Even with a trivial predicate that just looks at the index, the call takes ~70 ms for 3000 elements, i.e. tens of microseconds per element, while calling my lambda 3000 times in a plain P...
pyquery.pyquery.PyQuery.filter
0.326307
7.516159
23.033994
perf-pool-swesmith
gawel__pyquery.perf_3
gawel/pyquery
jyangballin/swesmith.x86_64.gawel_1776_pyquery.811cd048
610572bd9a288f3f8967a43bf0d3df257a6ee3be
diff --git a/pyquery/text.py b/pyquery/text.py index 9d68c20..12b2ece 100644 --- a/pyquery/text.py +++ b/pyquery/text.py @@ -17,11 +17,22 @@ SEPARATORS = {'br'} WHITESPACE_RE = re.compile('[\x20\x09\x0C\u200B\x0A\x0D]+') +HTML_WHITESPACE = '\x20\x09\x0C\u200B\x0A\x0D' + + def squash_html_whitespace(text): # ...
diff --git b/pyquery/text.py a/pyquery/text.py index 12b2ece..9d68c20 100644 --- b/pyquery/text.py +++ a/pyquery/text.py @@ -17,22 +17,11 @@ SEPARATORS = {'br'} WHITESPACE_RE = re.compile('[\x20\x09\x0C\u200B\x0A\x0D]+') -HTML_WHITESPACE = '\x20\x09\x0C\u200B\x0A\x0D' - - def squash_html_whitespace(text): # ...
import random import timeit import statistics from pyquery import PyQuery random.seed(0) paragraphs = [] for _ in range(200): tokens = ['%040x' % random.getrandbits(160) for _ in range(40)] paragraphs.append('<p>' + ' '.join(tokens) + '</p>') doc = PyQuery('<div>' + ''.join(paragraphs) + '</div>') # warm up d...
[ "tests/test_pyquery.py::TestAjax::test_serialize", "tests/test_pyquery.py::TestAjax::test_serialize_array", "tests/test_pyquery.py::TestAjax::test_serialize_dict", "tests/test_pyquery.py::TestAjax::test_serialize_pairs_filter_controls", "tests/test_pyquery.py::TestAjax::test_serialize_pairs_form_controls", ...
python -m pytest -q -rA -p no:cacheprovider
I extract the visible text of fairly large documents with `PyQuery(html).text()` — a container with a couple hundred paragraphs, a few hundred kilobytes of text in total. This takes about 40 ms per document, which is much slower than I expected: serializing the same document back to HTML, or even parsing it in the firs...
pyquery.pyquery.PyQuery.text
1.74477
6.718245
3.850505
perf-pool-swesmith
borntyping__python-colorlog.perf_0
borntyping/python-colorlog
jyangballin/swesmith.x86_64.borntyping_1776_python-colorlog.dfa10f59
4cba637107c6a8431b9f95d48b67677bce860305
diff --git a/colorlog/formatter.py b/colorlog/formatter.py index f011ca2..76fe832 100644 --- a/colorlog/formatter.py +++ b/colorlog/formatter.py @@ -49,8 +49,19 @@ class ColoredRecord: """ def __init__(self, record: logging.LogRecord, escapes: EscapeCodes) -> None: - self.__dict__.update(record.__dic...
diff --git b/colorlog/formatter.py a/colorlog/formatter.py index 76fe832..f011ca2 100644 --- b/colorlog/formatter.py +++ a/colorlog/formatter.py @@ -49,19 +49,8 @@ class ColoredRecord: """ def __init__(self, record: logging.LogRecord, escapes: EscapeCodes) -> None: - # Merge the record attributes wit...
import logging import statistics import timeit import colorlog formatter = colorlog.ColoredFormatter( "%(log_color)s%(levelname)-8s%(reset)s %(name)s: %(message)s", force_color=True, ) LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL] records = [] for i in range(50): ...
[ "colorlog/tests/test_colorlog.py::TestLevelFormatter::test_level_formatter", "colorlog/tests/test_colorlog.py::test_braces_style", "colorlog/tests/test_colorlog.py::test_colored_formatter", "colorlog/tests/test_colorlog.py::test_custom_colors", "colorlog/tests/test_colorlog.py::test_no_reset", "colorlog/t...
python -m pytest -q -rA -p no:cacheprovider
We use colorlog for a service that emits a fairly high volume of log lines (tens of thousands of records a minute across a handful of loggers). After upgrading, formatting a single record with a ColoredFormatter has become noticeably expensive: a tight loop that formats 50 pre-built LogRecords takes several millisecond...
colorlog.ColoredFormatter.format
1.529539
8.775855
5.737583
perf-pool-swesmith
borntyping__python-colorlog.perf_1
borntyping/python-colorlog
jyangballin/swesmith.x86_64.borntyping_1776_python-colorlog.dfa10f59
4cba637107c6a8431b9f95d48b67677bce860305
diff --git a/colorlog/formatter.py b/colorlog/formatter.py index f011ca2..d55b3f7 100644 --- a/colorlog/formatter.py +++ b/colorlog/formatter.py @@ -140,7 +140,12 @@ class ColoredFormatter(logging.Formatter): If _blank_escape_codes() returns True, all values will be an empty string. """ - cod...
diff --git b/colorlog/formatter.py a/colorlog/formatter.py index d55b3f7..f011ca2 100644 --- b/colorlog/formatter.py +++ a/colorlog/formatter.py @@ -140,12 +140,7 @@ class ColoredFormatter(logging.Formatter): If _blank_escape_codes() returns True, all values will be an empty string. """ - # R...
import logging import statistics import timeit import colorlog formatter = colorlog.ColoredFormatter( "%(log_color)s%(levelname)-8s%(reset)s %(name)s: %(message)s", force_color=True, ) LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL] records = [] for i in range(50): ...
[ "colorlog/tests/test_colorlog.py::TestLevelFormatter::test_level_formatter", "colorlog/tests/test_colorlog.py::test_braces_style", "colorlog/tests/test_colorlog.py::test_colored_formatter", "colorlog/tests/test_colorlog.py::test_custom_colors", "colorlog/tests/test_colorlog.py::test_no_reset", "colorlog/t...
python -m pytest -q -rA -p no:cacheprovider
Colorized logging is dominating the runtime of our batch jobs. Formatting a batch of 50 already-constructed LogRecords with a `ColoredFormatter` (simple `%`-style format with `log_color`/`reset`) takes tens of milliseconds, i.e. hundreds of microseconds per record, while the stdlib formatter handles the same records in...
colorlog.ColoredFormatter.format
0.760423
12.525091
16.471218
perf-pool-swesmith
borntyping__python-colorlog.perf_2
borntyping/python-colorlog
jyangballin/swesmith.x86_64.borntyping_1776_python-colorlog.dfa10f59
4cba637107c6a8431b9f95d48b67677bce860305
diff --git a/colorlog/formatter.py b/colorlog/formatter.py index f011ca2..178046d 100644 --- a/colorlog/formatter.py +++ b/colorlog/formatter.py @@ -170,10 +170,21 @@ class ColoredFormatter(logging.Formatter): """Add a reset code to the end of the message, if it's not already there.""" reset_escape_co...
diff --git b/colorlog/formatter.py a/colorlog/formatter.py index 178046d..f011ca2 100644 --- b/colorlog/formatter.py +++ a/colorlog/formatter.py @@ -170,21 +170,10 @@ class ColoredFormatter(logging.Formatter): """Add a reset code to the end of the message, if it's not already there.""" reset_escape_co...
import logging import statistics import timeit import colorlog formatter = colorlog.ColoredFormatter( "%(log_color)s%(levelname)-8s %(name)s: %(message)s", force_color=True, ) LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL] records = [] for i in range(50): record...
[ "colorlog/tests/test_colorlog.py::TestLevelFormatter::test_level_formatter", "colorlog/tests/test_colorlog.py::test_braces_style", "colorlog/tests/test_colorlog.py::test_colored_formatter", "colorlog/tests/test_colorlog.py::test_custom_colors", "colorlog/tests/test_colorlog.py::test_no_reset", "colorlog/t...
python -m pytest -q -rA -p no:cacheprovider
I'm benchmarking our logging pipeline and `ColoredFormatter.format()` is much slower than I expected. With a plain `%`-style format string and colour forced on, formatting 50 records takes several milliseconds — roughly 100µs per record — whereas the stdlib formatter does the same work in a few microseconds. The cost i...
colorlog.ColoredFormatter.format
1.51967
7.401843
4.87069
perf-pool-swesmith
borntyping__python-colorlog.perf_3
borntyping/python-colorlog
jyangballin/swesmith.x86_64.borntyping_1776_python-colorlog.dfa10f59
4cba637107c6a8431b9f95d48b67677bce860305
diff --git a/colorlog/escape_codes.py b/colorlog/escape_codes.py index 185b947..08747bd 100644 --- a/colorlog/escape_codes.py +++ b/colorlog/escape_codes.py @@ -102,4 +102,13 @@ for code in range(256): def parse_colors(string: str) -> str: """Return escape codes from a color sequence string.""" - return "".j...
diff --git b/colorlog/escape_codes.py a/colorlog/escape_codes.py index 08747bd..185b947 100644 --- b/colorlog/escape_codes.py +++ a/colorlog/escape_codes.py @@ -102,13 +102,4 @@ for code in range(256): def parse_colors(string: str) -> str: """Return escape codes from a color sequence string.""" - names = [na...
import statistics import timeit from colorlog.escape_codes import parse_colors SEQUENCES = [ "bold_red", "green", "fg_bold_yellow", "bg_light_blue", "fg_200", "bg_17", "thin_white", "reset", "bold,fg_cyan", "fg_bold_white,bg_red", ] def run(): for sequence in SEQUENCES: ...
[ "colorlog/tests/test_colorlog.py::TestLevelFormatter::test_level_formatter", "colorlog/tests/test_colorlog.py::test_braces_style", "colorlog/tests/test_colorlog.py::test_colored_formatter", "colorlog/tests/test_colorlog.py::test_custom_colors", "colorlog/tests/test_colorlog.py::test_no_reset", "colorlog/t...
python -m pytest -q -rA -p no:cacheprovider
We build our own colour theme on top of colorlog and resolve colour sequences (things like `"fg_bold_yellow"`, `"bg_light_blue"`, `"fg_200"`, `"bold,fg_cyan"`) at runtime, several times per rendered line. Resolving a single sequence now takes on the order of 10-20µs, which is thousands of times more than a dictionary l...
colorlog.escape_codes.parse_colors
0.341145
3.927111
11.511566
perf-pool-swesmith
arrow-py__arrow.perf_0
arrow-py/arrow
jyangballin/swesmith.x86_64.arrow-py_1776_arrow.1d70d009
e2ffa95da9e1b81ea793a8cd910bbf25593b1971
diff --git a/arrow/arrow.py b/arrow/arrow.py index 9d1f5e3..ebe156e 100644 --- a/arrow/arrow.py +++ b/arrow/arrow.py @@ -1500,9 +1500,11 @@ class Arrow: include_start = bounds[0] == "[" include_end = bounds[1] == "]" - target_ts = self.float_timestamp - start_ts = start.float_timestamp...
diff --git b/arrow/arrow.py a/arrow/arrow.py index ebe156e..9d1f5e3 100644 --- b/arrow/arrow.py +++ a/arrow/arrow.py @@ -1500,11 +1500,9 @@ class Arrow: include_start = bounds[0] == "[" include_end = bounds[1] == "]" - # normalize each endpoint to UTC first so that the comparison is - ...
import statistics import timeit import arrow BASE = 1600000000 targets = [arrow.get(BASE + i * 60) for i in range(500)] starts = [arrow.get(BASE + i * 60 - 30) for i in range(500)] ends = [arrow.get(BASE + i * 60 + 30) for i in range(500)] def run(): count = 0 for target, start, end in zip(targets, starts,...
[ "tests/test_arrow.py::TestArrowAttribute::test_float_timestamp", "tests/test_arrow.py::TestArrowAttribute::test_getattr_ambiguous", "tests/test_arrow.py::TestArrowAttribute::test_getattr_base", "tests/test_arrow.py::TestArrowAttribute::test_getattr_dt_value", "tests/test_arrow.py::TestArrowAttribute::test_g...
python -m pytest -q -rA -p no:cacheprovider
I have a scheduling service that filters events by checking whether each event timestamp falls inside a candidate window, so I end up calling `is_between` a few hundred thousand times per request batch. This is conceptually just three instant comparisons, but profiling shows it is by far the hottest thing in my code: f...
arrow.arrow.Arrow.is_between
0.485934
1.542139
3.173553
perf-pool-swesmith
arrow-py__arrow.perf_1
arrow-py/arrow
jyangballin/swesmith.x86_64.arrow-py_1776_arrow.1d70d009
e2ffa95da9e1b81ea793a8cd910bbf25593b1971
diff --git a/arrow/arrow.py b/arrow/arrow.py index 9d1f5e3..0f77983 100644 --- a/arrow/arrow.py +++ b/arrow/arrow.py @@ -807,10 +807,14 @@ class Arrow: return int((self.month - 1) / self._MONTHS_PER_QUARTER) + 1 if not name.startswith("_"): - value: Optional[Any] = getattr(self._datet...
diff --git b/arrow/arrow.py a/arrow/arrow.py index 0f77983..9d1f5e3 100644 --- b/arrow/arrow.py +++ a/arrow/arrow.py @@ -807,14 +807,10 @@ class Arrow: return int((self.month - 1) / self._MONTHS_PER_QUARTER) + 1 if not name.startswith("_"): - # only delegate names that the wrapped dat...
import statistics import timeit import arrow BASE = 1600000000 arrows = [arrow.get(BASE + i * 3671) for i in range(200)] def run(): total = 0 for a in arrows: total += ( a.year + a.month + a.day + a.hour + a.minute + a.second ...
[ "tests/test_arrow.py::TestArrowAttribute::test_float_timestamp", "tests/test_arrow.py::TestArrowAttribute::test_getattr_ambiguous", "tests/test_arrow.py::TestArrowAttribute::test_getattr_base", "tests/test_arrow.py::TestArrowAttribute::test_getattr_dt_value", "tests/test_arrow.py::TestArrowAttribute::test_g...
python -m pytest -q -rA -p no:cacheprovider
I'm exporting a few hundred thousand rows of time series data and for each row I read the individual date/time components off the Arrow object (`year`, `month`, `day`, `hour`, `minute`, `second`, `microsecond`) to build a CSV. Reading those seven fields off one object costs tens of microseconds, while reading the same ...
arrow.arrow.Arrow.__getattr__
0.610046
10.060459
16.4913
perf-pool-swesmith
arrow-py__arrow.perf_2
arrow-py/arrow
jyangballin/swesmith.x86_64.arrow-py_1776_arrow.1d70d009
e2ffa95da9e1b81ea793a8cd910bbf25593b1971
diff --git a/arrow/arrow.py b/arrow/arrow.py index 9d1f5e3..bde72bc 100644 --- a/arrow/arrow.py +++ b/arrow/arrow.py @@ -5,6 +5,7 @@ replacement. """ import calendar +import copy import re import sys from datetime import date @@ -934,7 +935,7 @@ class Arrow: """ - return self.fromdatetime(sel...
diff --git b/arrow/arrow.py a/arrow/arrow.py index bde72bc..9d1f5e3 100644 --- b/arrow/arrow.py +++ a/arrow/arrow.py @@ -5,7 +5,6 @@ replacement. """ import calendar -import copy import re import sys from datetime import date @@ -935,7 +934,7 @@ class Arrow: """ - return copy.deepcopy(self) +...
import statistics import timeit import arrow BASE = 1600000000 arrows = [arrow.get(BASE + i * 97) for i in range(500)] def run(): out = [] for a in arrows: out.append(a.clone()) return len(out) run() results = timeit.repeat("run()", globals=globals(), number=250, repeat=5) print(f"Mean: {st...
[ "tests/test_api.py::TestModule::test_factory", "tests/test_api.py::TestModule::test_get", "tests/test_api.py::TestModule::test_now", "tests/test_api.py::TestModule::test_utcnow", "tests/test_arrow.py::TestArrowAttribute::test_float_timestamp", "tests/test_arrow.py::TestArrowAttribute::test_getattr_ambiguo...
python -m pytest -q -rA -p no:cacheprovider
My pipeline snapshots timestamps defensively: every record that enters a processing stage gets a copy of its Arrow object so downstream stages can't accidentally share state. Copying 500 objects takes over 15 ms, i.e. ~30 microseconds per copy, which dominates the stage even though the objects only wrap a single immuta...
arrow.arrow.Arrow.clone
0.272013
2.073645
7.623324
perf-pool-swesmith
theskumar__python-dotenv.perf_0
theskumar/python-dotenv
jyangballin/swesmith.x86_64.theskumar_1776_python-dotenv.2b8635b7
c53aad5a94cb710edc8404146e04905964c60491
diff --git a/src/dotenv/parser.py b/src/dotenv/parser.py index 735f14a..cf68aba 100644 --- a/src/dotenv/parser.py +++ b/src/dotenv/parser.py @@ -88,10 +88,14 @@ class Reader: return result def read_regex(self, regex: Pattern[str]) -> Sequence[str]: - match = regex.match(self.string, self.position...
diff --git b/src/dotenv/parser.py a/src/dotenv/parser.py index cf68aba..735f14a 100644 --- b/src/dotenv/parser.py +++ a/src/dotenv/parser.py @@ -88,14 +88,10 @@ class Reader: return result def read_regex(self, regex: Pattern[str]) -> Sequence[str]: - # Match the pattern against the part of the in...
import io import statistics import timeit from dotenv import dotenv_values lines = [] for i in range(6000): lines.append("SERVICE_SETTING_{}=value_number_{}_abcdefghij".format(i, i)) content = "\n".join(lines) + "\n" def run(): return dotenv_values(stream=io.StringIO(content), interpolate=False) run() N ...
[ "tests/test_main.py::test_dotenv_values_file", "tests/test_main.py::test_dotenv_values_file_stream", "tests/test_main.py::test_dotenv_values_string_io[env0-a=$b-False-expected0]", "tests/test_main.py::test_dotenv_values_string_io[env1-a=$b-True-expected1]", "tests/test_main.py::test_dotenv_values_string_io[...
python -m pytest -q -rA -p no:cacheprovider
We keep a fairly large generated `.env` file (a few thousand entries) that we load with `dotenv_values(stream=...)` at service start-up, and it has become surprisingly slow: loading a ~300 KB env file takes on the order of half a second, while the same file loaded with a naive `line.split("=")` loop is done in a few mi...
dotenv.dotenv_values
2.280116
7.487511
3.283829
perf-pool-swesmith
theskumar__python-dotenv.perf_1
theskumar/python-dotenv
jyangballin/swesmith.x86_64.theskumar_1776_python-dotenv.2b8635b7
c53aad5a94cb710edc8404146e04905964c60491
diff --git a/src/dotenv/main.py b/src/dotenv/main.py index 052de05..67b6d06 100644 --- a/src/dotenv/main.py +++ b/src/dotenv/main.py @@ -239,15 +239,19 @@ def resolve_variables( if value is None: result = None else: - atoms = parse_variables(value) - env: Dict[str, O...
diff --git b/src/dotenv/main.py a/src/dotenv/main.py index 67b6d06..052de05 100644 --- b/src/dotenv/main.py +++ a/src/dotenv/main.py @@ -239,19 +239,15 @@ def resolve_variables( if value is None: result = None else: - parts = [] - for atom in parse_variables(value): ...
import io import statistics import timeit from dotenv import dotenv_values lines = [] for i in range(10): lines.append("BASE_{}=base_value_{}".format(i, i)) refs = "-".join("${{BASE_{}}}".format(j) for j in range(10)) for i in range(600): lines.append("COMPOSED_{}={}-tail{}".format(i, refs, i)) content = "\n"...
[ "tests/test_main.py::test_dotenv_values_file", "tests/test_main.py::test_dotenv_values_file_stream", "tests/test_main.py::test_dotenv_values_string_io[env0-a=$b-False-expected0]", "tests/test_main.py::test_dotenv_values_string_io[env1-a=$b-True-expected1]", "tests/test_main.py::test_dotenv_values_string_io[...
python -m pytest -q -rA -p no:cacheprovider
Our `.env` file uses POSIX-style interpolation heavily: a handful of base variables and then several hundred entries that each stitch together ten or so `${...}` references. Calling `dotenv_values()` on that file takes hundreds of milliseconds, which is very noticeable in test setup where we reload the config repeatedl...
dotenv.dotenv_values
1.452333
13.145438
9.051257
perf-pool-swesmith
theskumar__python-dotenv.perf_3
theskumar/python-dotenv
jyangballin/swesmith.x86_64.theskumar_1776_python-dotenv.2b8635b7
c53aad5a94cb710edc8404146e04905964c60491
diff --git a/src/dotenv/parser.py b/src/dotenv/parser.py index 735f14a..36688e3 100644 --- a/src/dotenv/parser.py +++ b/src/dotenv/parser.py @@ -115,7 +115,17 @@ def parse_key(reader: Reader) -> Optional[str]: def parse_unquoted_value(reader: Reader) -> str: (part,) = reader.read_regex(_unquoted_value) - ret...
diff --git b/src/dotenv/parser.py a/src/dotenv/parser.py index 36688e3..735f14a 100644 --- b/src/dotenv/parser.py +++ a/src/dotenv/parser.py @@ -115,17 +115,7 @@ def parse_key(reader: Reader) -> Optional[str]: def parse_unquoted_value(reader: Reader) -> str: (part,) = reader.read_regex(_unquoted_value) - # A...
import io import random import statistics import timeit from dotenv import dotenv_values rng = random.Random(0) alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/" lines = [] for i in range(600): value = "".join(rng.choice(alphabet) for _ in range(800)) lines.append("LONG_SETTING_{}=...
[ "tests/test_main.py::test_dotenv_values_file", "tests/test_main.py::test_dotenv_values_file_stream", "tests/test_main.py::test_dotenv_values_string_io[env0-a=$b-False-expected0]", "tests/test_main.py::test_dotenv_values_string_io[env1-a=$b-True-expected1]", "tests/test_main.py::test_dotenv_values_string_io[...
python -m pytest -q -rA -p no:cacheprovider
We store a few hundred long unquoted values in our `.env` (connection strings, long URLs, base64-ish blobs — typically 500-1000 characters each) and reading that file with `dotenv_values()` is much slower than it should be: about 80 ms for a 600-line file, versus a few milliseconds for a file with the same number of sh...
dotenv.dotenv_values
5.022154
19.631627
3.909006
perf-pool-swesmith
stanfordnlp__string2string.perf_0
stanfordnlp/string2string
jyangballin/swesmith.x86_64.stanfordnlp_1776_string2string.c4a72f59
99542a900f8fb483578767e50c11498f2ec11ee9
diff --git a/string2string/alignment/classical.py b/string2string/alignment/classical.py index 86c8039..562ec4a 100644 --- a/string2string/alignment/classical.py +++ b/string2string/alignment/classical.py @@ -1213,18 +1213,20 @@ class LongestCommonSubstring(LongestCommonSubsequence): # Dynamic programming solu...
diff --git b/string2string/alignment/classical.py a/string2string/alignment/classical.py index 562ec4a..86c8039 100644 --- b/string2string/alignment/classical.py +++ a/string2string/alignment/classical.py @@ -1213,20 +1213,18 @@ class LongestCommonSubstring(LongestCommonSubsequence): # Dynamic programming solu...
import statistics import timeit from string2string.alignment.classical import LongestCommonSubstring # Build two realistic tandem-repeat DNA sequences (with a few point mutations). seq1 = "ACGT" * 40 chars = list("ACGT" * 40) for pos in (37, 91, 143): chars[pos] = "T" if chars[pos] != "T" else "A" seq2 = "".join(...
[ "tests/test_alignment.py::AlignmentTestCase::test_dtw", "tests/test_alignment.py::AlignmentTestCase::test_hiirschberg", "tests/test_alignment.py::AlignmentTestCase::test_longest_common_subsequence", "tests/test_alignment.py::AlignmentTestCase::test_longest_common_subsubtring", "tests/test_alignment.py::Alig...
python -m pytest -q -rA -p no:cacheprovider
I use the longest-common-substring utility to compare DNA sequences that contain tandem repeats (e.g. a few hundred bases of "ACGT"-style repeats with a couple of point mutations). For two sequences of only ~160 bases each, a single comparison takes tens of milliseconds, and when I loop over a few thousand pairs it bec...
string2string.alignment.classical.LongestCommonSubstring.compute
0.214217
0.890219
4.155677
perf-pool-swesmith
stanfordnlp__string2string.perf_3
stanfordnlp/string2string
jyangballin/swesmith.x86_64.stanfordnlp_1776_string2string.c4a72f59
99542a900f8fb483578767e50c11498f2ec11ee9
diff --git a/string2string/alignment/classical.py b/string2string/alignment/classical.py index 86c8039..679ac9c 100644 --- a/string2string/alignment/classical.py +++ b/string2string/alignment/classical.py @@ -607,13 +607,17 @@ class Hirschberg(NeedlemanWunsch): # Get the middle index of str1. ...
diff --git b/string2string/alignment/classical.py a/string2string/alignment/classical.py index 679ac9c..86c8039 100644 --- b/string2string/alignment/classical.py +++ a/string2string/alignment/classical.py @@ -607,17 +607,13 @@ class Hirschberg(NeedlemanWunsch): # Get the middle index of str1. ...
import random import statistics import timeit from string2string.alignment.classical import Hirschberg random.seed(7) seq1 = "".join(random.choice("ACGT") for _ in range(40)) seq2 = "".join(random.choice("ACGT") for _ in range(40)) aligner = Hirschberg() # Warm-up aligner.get_alignment(seq1, seq2) N = 80 times = t...
[ "tests/test_alignment.py::AlignmentTestCase::test_dtw", "tests/test_alignment.py::AlignmentTestCase::test_hiirschberg", "tests/test_alignment.py::AlignmentTestCase::test_longest_common_subsequence", "tests/test_alignment.py::AlignmentTestCase::test_longest_common_subsubtring", "tests/test_alignment.py::Alig...
python -m pytest -q -rA -p no:cacheprovider
I am using the Hirschberg global aligner on pairs of short protein/DNA-like sequences (about 40 symbols each) and it is far slower than I expected: a single alignment takes around 60-70 ms, whereas the plain Needleman-Wunsch aligner returns in a few milliseconds on the same pair. Since Hirschberg is advertised as havin...
string2string.alignment.classical.Hirschberg.get_alignment
0.535535
6.431246
12.009018
perf-pool-swesmith
paramiko__paramiko.perf_0
paramiko/paramiko
jyangballin/swesmith.x86_64.paramiko_1776_paramiko.23f92003
1609889bdc08f5796f2a96e5439db4b7278652cb
diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py index bc7f298..6bbbf73 100644 --- a/paramiko/auth_handler.py +++ b/paramiko/auth_handler.py @@ -777,7 +777,10 @@ Error Message: {} prompts = m.get_int() prompt_list = [] for i in range(prompts): - prompt_list.append((...
diff --git b/paramiko/auth_handler.py a/paramiko/auth_handler.py index 6bbbf73..bc7f298 100644 --- b/paramiko/auth_handler.py +++ a/paramiko/auth_handler.py @@ -777,10 +777,7 @@ Error Message: {} prompts = m.get_int() prompt_list = [] for i in range(prompts): - prompt = m.get_text(...
import statistics import timeit from paramiko.auth_handler import AuthHandler from paramiko.message import Message class FakeTransport: server_mode = False auth_timeout = None def _send_message(self, m): pass def _log(self, *args): pass N_PROMPTS = 15000 builder = Message() build...
[ "tests/test_client.py::PasswordPassphraseTests::test_passphrase_kwarg_not_used_for_password_auth", "tests/test_client.py::PasswordPassphraseTests::test_passphrase_kwarg_used_for_key_passphrase", "tests/test_client.py::PasswordPassphraseTests::test_password_kwarg_not_used_for_passphrase_when_passphrase_kwarg_giv...
python -m pytest -q -rA -p no:cacheprovider
We use keyboard-interactive auth against an appliance whose challenge contains a very large number of prompts (it batches thousands of one-time-code questions into a single info request). Handling that single server challenge on the client side takes hundreds of milliseconds of pure CPU, which is far more than the time...
paramiko.auth_handler.AuthHandler._parse_userauth_info_request
1.062281
12.37572
11.650139
perf-pool-swesmith
paramiko__paramiko.perf_1
paramiko/paramiko
jyangballin/swesmith.x86_64.paramiko_1776_paramiko.23f92003
1609889bdc08f5796f2a96e5439db4b7278652cb
diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py index bc7f298..2e6b7db 100644 --- a/paramiko/auth_handler.py +++ b/paramiko/auth_handler.py @@ -795,7 +795,9 @@ Error Message: {} n = m.get_int() responses = [] for i in range(n): - responses.append(m.get_text()) + ...
diff --git b/paramiko/auth_handler.py a/paramiko/auth_handler.py index 2e6b7db..bc7f298 100644 --- b/paramiko/auth_handler.py +++ a/paramiko/auth_handler.py @@ -795,9 +795,7 @@ Error Message: {} n = m.get_int() responses = [] for i in range(n): - response = m.get_text() - ...
import statistics import timeit from paramiko.auth_handler import AuthHandler from paramiko.common import AUTH_SUCCESSFUL from paramiko.message import Message class FakeServer: def check_auth_interactive_response(self, responses): return AUTH_SUCCESSFUL class FakeTransport: server_mode = True a...
[ "tests/test_client.py::PasswordPassphraseTests::test_passphrase_kwarg_not_used_for_password_auth", "tests/test_client.py::PasswordPassphraseTests::test_passphrase_kwarg_used_for_key_passphrase", "tests/test_client.py::PasswordPassphraseTests::test_password_kwarg_not_used_for_passphrase_when_passphrase_kwarg_giv...
python -m pytest -q -rA -p no:cacheprovider
I'm running paramiko in server mode with a keyboard-interactive flow where the client answers a large batch of prompts in one go (a few thousand responses in a single info response packet). Processing that one packet burns close to a second of CPU inside paramiko before my server callback is ever invoked, and during th...
paramiko.auth_handler.AuthHandler._parse_userauth_info_response
0.651182
9.754331
14.979428
perf-pool-swesmith
paramiko__paramiko.perf_2
paramiko/paramiko
jyangballin/swesmith.x86_64.paramiko_1776_paramiko.23f92003
1609889bdc08f5796f2a96e5439db4b7278652cb
diff --git a/paramiko/channel.py b/paramiko/channel.py index 25326ca..32ec825 100644 --- a/paramiko/channel.py +++ b/paramiko/channel.py @@ -325,7 +325,9 @@ class Channel(ClosingContextManager): `.SSHException` -- if any of the environment variables was rejected by the server or the channel wa...
diff --git b/paramiko/channel.py a/paramiko/channel.py index 32ec825..25326ca 100644 --- b/paramiko/channel.py +++ a/paramiko/channel.py @@ -325,9 +325,7 @@ class Channel(ClosingContextManager): `.SSHException` -- if any of the environment variables was rejected by the server or the channel wa...
import statistics import timeit from paramiko.channel import Channel class FakeTransport: def _send_user_message(self, m): pass def _sanitize_packet_size(self, size): return size def get_log_channel(self): return "paramiko.transport" chan = Channel(1) chan._set_transport(FakeT...
[ "tests/test_channelfile.py::TestChannelFile::test_can_override_mode_and_bufsize", "tests/test_channelfile.py::TestChannelFile::test_defaults_to_unbuffered_reading", "tests/test_channelfile.py::TestChannelFile::test_read_recvs_from_channel", "tests/test_channelfile.py::TestChannelFile::test_write_calls_channel...
python -m pytest -q -rA -p no:cacheprovider
We push a fairly large environment (a couple of thousand variables coming out of our build system config) onto a channel before executing a remote command. Doing this takes tens of milliseconds of CPU per channel even though each variable is just a tiny request message; with several channels per job this adds real late...
paramiko.channel.Channel.update_environment
0.836959
8.21813
9.819032
perf-pool-swesmith
paramiko__paramiko.perf_3
paramiko/paramiko
jyangballin/swesmith.x86_64.paramiko_1776_paramiko.23f92003
1609889bdc08f5796f2a96e5439db4b7278652cb
diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py index bc7f298..1aa0f5c 100644 --- a/paramiko/auth_handler.py +++ b/paramiko/auth_handler.py @@ -541,9 +541,13 @@ Error Message: {} m.add_string(q.instructions) m.add_string(bytes()) m.add_int(len(q.prompts)) + prompt_data...
diff --git b/paramiko/auth_handler.py a/paramiko/auth_handler.py index 1aa0f5c..bc7f298 100644 --- b/paramiko/auth_handler.py +++ a/paramiko/auth_handler.py @@ -541,13 +541,9 @@ Error Message: {} m.add_string(q.instructions) m.add_string(bytes()) m.add_int(len(q.prompts)) - prompt_data...
import statistics import timeit from paramiko.auth_handler import AuthHandler from paramiko.message import Message from paramiko.server import InteractiveQuery N_PROMPTS = 6000 QUERY = InteractiveQuery("Verification", "Answer all prompts") for i in range(N_PROMPTS): QUERY.add_prompt("Token code {}: ".format(i),...
[ "tests/test_client.py::PasswordPassphraseTests::test_passphrase_kwarg_not_used_for_password_auth", "tests/test_client.py::PasswordPassphraseTests::test_passphrase_kwarg_used_for_key_passphrase", "tests/test_client.py::PasswordPassphraseTests::test_password_kwarg_not_used_for_passphrase_when_passphrase_kwarg_giv...
python -m pytest -q -rA -p no:cacheprovider
Our SSH server implementation answers keyboard-interactive auth requests with a large generated challenge (thousands of prompts, one per pending token, in a single query). Serving one such auth request costs us ~60ms of CPU inside paramiko, which shows up as a noticeable stall when many clients connect at once. The pro...
paramiko.auth_handler.AuthHandler._parse_userauth_request
0.487882
1.832862
3.756774
perf-pool-swesmith
burnash__gspread.perf_0
burnash/gspread
jyangballin/swesmith.x86_64.burnash_1776_gspread.a8be3b96
897b81366e81c943d9ffa67c0daa0a7ab589fe32
diff --git a/gspread/utils.py b/gspread/utils.py index 6daac86..fba2638 100644 --- a/gspread/utils.py +++ b/gspread/utils.py @@ -631,7 +631,15 @@ def wid_to_gid(wid: str) -> str: def rightpad(row: List[Any], max_len: int, padding_value: Any = "") -> List[Any]: pad_len = max_len - len(row) - return row + ([pa...
diff --git b/gspread/utils.py a/gspread/utils.py index fba2638..6daac86 100644 --- b/gspread/utils.py +++ a/gspread/utils.py @@ -631,15 +631,7 @@ def wid_to_gid(wid: str) -> str: def rightpad(row: List[Any], max_len: int, padding_value: Any = "") -> List[Any]: pad_len = max_len - len(row) - if pad_len == 0: ...
import random import statistics import timeit from gspread.utils import fill_gaps random.seed(1234) ROWS = 2000 COLS = 40 matrix = [ [str(random.randint(0, 100)) for _ in range(random.randint(1, 35))] for _ in range(ROWS) ] def run(): return fill_gaps(matrix, rows=ROWS, cols=COLS) run() N = 500 tim...
[ "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_improper_range", "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_other_directions", "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_simple", "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_unbounded", "tests/utils_test.py::UtilsTest...
python -m pytest -q -rA -p no:cacheprovider
I use gspread's value-matrix padding helper to normalize ragged rows coming back from the Sheets API before feeding them into pandas. With a sheet of a couple thousand rows where most rows are much shorter than the widest row (so a lot of trailing empty cells have to be added), this step now takes noticeably longer tha...
gspread.utils.fill_gaps
0.560293
4.905114
8.754547
perf-pool-swesmith
burnash__gspread.perf_1
burnash/gspread
jyangballin/swesmith.x86_64.burnash_1776_gspread.a8be3b96
897b81366e81c943d9ffa67c0daa0a7ab589fe32
diff --git a/gspread/utils.py b/gspread/utils.py index 6daac86..9f0a628 100644 --- a/gspread/utils.py +++ b/gspread/utils.py @@ -703,7 +703,17 @@ def cell_list_to_rect(cell_list: List["Cell"]) -> List[List[Optional[str]]]: # contains all of the values for one row. The Google API requires a rectangle # of upda...
diff --git b/gspread/utils.py a/gspread/utils.py index 9f0a628..6daac86 100644 --- b/gspread/utils.py +++ a/gspread/utils.py @@ -703,17 +703,7 @@ def cell_list_to_rect(cell_list: List["Cell"]) -> List[List[Optional[str]]]: # contains all of the values for one row. The Google API requires a rectangle # of upda...
import statistics import timeit from gspread.cell import Cell from gspread.utils import cell_list_to_rect ROWS = 25 COLS = 400 cells = [ Cell(r + 1, c + 1, "v{}-{}".format(r, c)) for r in range(ROWS) for c in range(COLS) ] def run(): return cell_list_to_rect(cells) run() N = 60 timings = timeit....
[ "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_improper_range", "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_other_directions", "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_simple", "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_unbounded", "tests/utils_test.py::UtilsTest...
python -m pytest -q -rA -p no:cacheprovider
I build a list of Cell objects (one per cell of a block I want to write back) and hand it to gspread's helper that turns a cell list into a rectangular matrix before doing a batch update. For a block of about 25 rows by 400 columns (10k cells) this conversion takes tens of milliseconds, and when I do it repeatedly in a...
gspread.utils.cell_list_to_rect
0.525701
3.428287
6.521364
perf-pool-swesmith
burnash__gspread.perf_2
burnash/gspread
jyangballin/swesmith.x86_64.burnash_1776_gspread.a8be3b96
897b81366e81c943d9ffa67c0daa0a7ab589fe32
diff --git a/gspread/utils.py b/gspread/utils.py index 6daac86..2b33556 100644 --- a/gspread/utils.py +++ b/gspread/utils.py @@ -982,7 +982,15 @@ def to_records( ] """ - return [dict(zip(headers, row)) for row in values] + records: List[Dict[str, Union[str, int, float]]] = [] + + for row in val...
diff --git b/gspread/utils.py a/gspread/utils.py index 2b33556..6daac86 100644 --- b/gspread/utils.py +++ a/gspread/utils.py @@ -982,15 +982,7 @@ def to_records( ] """ - records: List[Dict[str, Union[str, int, float]]] = [] - - for row in values: - record: Dict[str, Union[str, int, float]] ...
import statistics import timeit from gspread.utils import to_records ROWS = 2000 NCOLS = 15 headers = ["col{}".format(i) for i in range(NCOLS)] values = [["r{}c{}".format(r, c) for c in range(NCOLS)] for r in range(ROWS)] def run(): return to_records(headers, values) run() N = 300 timings = timeit.repeat(ru...
[ "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_improper_range", "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_other_directions", "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_simple", "tests/utils_test.py::UtilsTest::test_a1_to_grid_range_unbounded", "tests/utils_test.py::UtilsTest...
python -m pytest -q -rA -p no:cacheprovider
I convert sheet values into a list of dictionaries with gspread's records helper (the same code path used by get_records). For a sheet with ~2000 rows and 15 columns this conversion alone takes a surprisingly long time — it is now clearly the slowest part of my loop over several sheets, even though it is only zipping h...
gspread.utils.to_records
0.674052
2.428474
3.602798
perf-pool-swesmith
mahmoud__boltons.perf_0
mahmoud/boltons
jyangballin/swesmith.x86_64.mahmoud_1776_boltons.3bfcfdd0
1c4d56a384cef82eeb63232cbd266ce2482bbd90
diff --git a/boltons/iterutils.py b/boltons/iterutils.py index e0a5b90..f5f12bd 100644 --- a/boltons/iterutils.py +++ b/boltons/iterutils.py @@ -818,11 +818,11 @@ def unique_iter(src, key=None): def key_func(x): return getattr(x, key, x) else: raise TypeError('"key" expected a string or callable,...
diff --git b/boltons/iterutils.py a/boltons/iterutils.py index f5f12bd..e0a5b90 100644 --- b/boltons/iterutils.py +++ a/boltons/iterutils.py @@ -818,11 +818,11 @@ def unique_iter(src, key=None): def key_func(x): return getattr(x, key, x) else: raise TypeError('"key" expected a string or callable,...
import random import statistics import timeit from boltons.iterutils import unique random.seed(42) src = [random.randrange(500) for _ in range(20000)] # warmup unique(src) times = timeit.repeat(lambda: unique(src), number=150, repeat=5) print("Mean: " + str(statistics.mean(times))) print("Std Dev: " + str(statistic...
[ "tests/test_iterutils.py::TestFirst::test_default_value", "tests/test_iterutils.py::TestFirst::test_empty_iterables", "tests/test_iterutils.py::TestFirst::test_selection", "tests/test_iterutils.py::TestGetPath::test_depth_one", "tests/test_iterutils.py::TestGetPath::test_depth_two", "tests/test_iterutils....
python -m pytest -q -rA -p no:cacheprovider
I use the de-duplication helper in boltons.iterutils to normalize event streams before storing them. On a list of ~20k records that only contains a few hundred distinct values, deduplicating takes tens of milliseconds per call, and when I run it over a few hundred batches it dominates my job runtime. What surprises me ...
boltons.iterutils.unique
0.209806
3.138713
14.960047
perf-pool-swesmith
mahmoud__boltons.perf_3
mahmoud/boltons
jyangballin/swesmith.x86_64.mahmoud_1776_boltons.3bfcfdd0
1c4d56a384cef82eeb63232cbd266ce2482bbd90
diff --git a/boltons/iterutils.py b/boltons/iterutils.py index e0a5b90..5f6c103 100644 --- a/boltons/iterutils.py +++ b/boltons/iterutils.py @@ -164,7 +164,8 @@ def split_iter(src, sep=None, maxsplit=None): if callable(sep): sep_func = sep elif not is_scalar(sep): - sep = frozenset(sep) + ...
diff --git b/boltons/iterutils.py a/boltons/iterutils.py index 5f6c103..e0a5b90 100644 --- b/boltons/iterutils.py +++ a/boltons/iterutils.py @@ -164,8 +164,7 @@ def split_iter(src, sep=None, maxsplit=None): if callable(sep): sep_func = sep elif not is_scalar(sep): - # materialize so generators...
import random import statistics import timeit from boltons.iterutils import split random.seed(1234) src = [random.randrange(1000) for _ in range(20000)] sep = list(range(500, 1000)) # warmup split(src, sep=sep) times = timeit.repeat(lambda: split(src, sep=sep), number=100, repeat=5) print("Mean: " + str(statistics....
[ "tests/test_iterutils.py::TestFirst::test_default_value", "tests/test_iterutils.py::TestFirst::test_empty_iterables", "tests/test_iterutils.py::TestFirst::test_selection", "tests/test_iterutils.py::TestGetPath::test_depth_one", "tests/test_iterutils.py::TestGetPath::test_depth_two", "tests/test_iterutils....
python -m pytest -q -rA -p no:cacheprovider
I'm splitting a long token stream (20k tokens) on a set of about 500 possible delimiter values using the iterable-splitting helper in boltons.iterutils. It takes ~50ms per call, which is far more than I expected for a single pass over 20k items, and it gets noticeably worse as I add more delimiter values to my separato...
boltons.iterutils.split
0.263331
3.20256
12.161745
perf-pool-swesmith
mido__mido.perf_1
mido/mido
jyangballin/swesmith.x86_64.mido_1776_mido.a0158ff9
e2c2f8cdd415f6924acb7a5b2351118428522e2b
diff --git a/mido/messages/messages.py b/mido/messages/messages.py index 9f760a4..3cd8bc0 100644 --- a/mido/messages/messages.py +++ b/mido/messages/messages.py @@ -131,12 +131,6 @@ class Message(BaseMessage): The skip_checks arg can be used to bypass validation of message attributes and should be use...
diff --git b/mido/messages/messages.py a/mido/messages/messages.py index 3cd8bc0..9f760a4 100644 --- b/mido/messages/messages.py +++ a/mido/messages/messages.py @@ -131,6 +131,12 @@ class Message(BaseMessage): The skip_checks arg can be used to bypass validation of message attributes and should be use...
import statistics import timeit import mido msgs = [] for i in range(2000): msgs.append(mido.Message('note_on', channel=i % 16, note=i % 128, velocity=(i * 3) % 128, time=i)) def run(): return...
[ "tests/messages/test_messages.py::test_compare_with_nonmessage", "tests/messages/test_messages.py::test_copy", "tests/messages/test_messages.py::test_copy_can_have_same_type", "tests/messages/test_messages.py::test_copy_cant_change_type", "tests/messages/test_messages.py::test_copy_handles_data_generator", ...
python -m pytest -q -rA -p no:cacheprovider
I keep a large list of Message objects around and duplicate them before handing them off to different consumers (basically `msg.copy()` with no arguments, a few hundred thousand times). This plain duplication is surprisingly expensive: copying 2000 messages takes several milliseconds, so my dispatch loop spends most of...
mido.Message.copy
0.451364
7.272995
16.113352
perf-pool-swesmith
mido__mido.perf_3
mido/mido
jyangballin/swesmith.x86_64.mido_1776_mido.a0158ff9
e2c2f8cdd415f6924acb7a5b2351118428522e2b
diff --git a/mido/midifiles/meta.py b/mido/midifiles/meta.py index 0a7e2ba..82a0cc2 100644 --- a/mido/midifiles/meta.py +++ b/mido/midifiles/meta.py @@ -540,7 +540,16 @@ class MetaMessage(BaseMessage): __setattr__ = _setattr def bytes(self): - spec = _META_SPEC_BY_TYPE[self.type] + # Find the ...
diff --git b/mido/midifiles/meta.py a/mido/midifiles/meta.py index 82a0cc2..0a7e2ba 100644 --- b/mido/midifiles/meta.py +++ a/mido/midifiles/meta.py @@ -540,16 +540,7 @@ class MetaMessage(BaseMessage): __setattr__ = _setattr def bytes(self): - # Find the spec for this message type by name. - s...
import statistics import timeit import mido msgs = [] for i in range(500): kind = i % 5 if kind == 0: msgs.append(mido.MetaMessage('set_tempo', tempo=500000 + i, time=i)) elif kind == 1: msgs.append(mido.MetaMessage('track_name', name=f'track {i}', time=i)) elif kind == 2: msgs...
[ "tests/midifiles/test_meta.py::TestKeySignature::test_bad_key_sig_throws_key_signature_error[bad_key_sig0]", "tests/midifiles/test_meta.py::TestKeySignature::test_bad_key_sig_throws_key_signature_error[bad_key_sig1]", "tests/midifiles/test_meta.py::TestKeySignature::test_bad_key_sig_throws_key_signature_error[b...
python -m pytest -q -rA -p no:cacheprovider
I build MIDI files that contain a lot of meta events (lyrics, markers, tempo and time signature changes) and encoding those meta messages to bytes is very slow. Calling `.bytes()` on a few hundred meta messages takes around 10 ms, i.e. tens of microseconds per message, while encoding ordinary note messages is essential...
mido.MetaMessage.bytes
0.296403
2.314003
7.806954
perf-pool-swesmith
Suor__funcy.perf_0
Suor/funcy
jyangballin/swesmith.x86_64.suor_1776_funcy.207a7810
4895f919dfd83e24f0334421c5bac104b69d8946
diff --git a/funcy/colls.py b/funcy/colls.py index 6acfd53..25632f5 100644 --- a/funcy/colls.py +++ b/funcy/colls.py @@ -104,13 +104,18 @@ def join_with(f, dicts, strict=False): elif not strict and len(dicts) == 1: return dicts[0] + items = [list(iteritems(c)) for c in dicts] + + # Collect all the...
diff --git b/funcy/colls.py a/funcy/colls.py index 25632f5..6acfd53 100644 --- b/funcy/colls.py +++ a/funcy/colls.py @@ -104,18 +104,13 @@ def join_with(f, dicts, strict=False): elif not strict and len(dicts) == 1: return dicts[0] - items = [list(iteritems(c)) for c in dicts] - - # Collect all the...
import random import timeit from funcy import merge_with random.seed(0) KEYS = ['key%02d' % i for i in range(20)] DICTS = [{k: random.randint(0, 100) for k in KEYS} for _ in range(20)] def run(): return merge_with(sum, *DICTS) run() N = 8000 times = timeit.repeat("run()", globals=globals(), number=N, repeat=...
[ "tests/test_colls.py::test_all", "tests/test_colls.py::test_all_extended", "tests/test_colls.py::test_any", "tests/test_colls.py::test_compact", "tests/test_colls.py::test_del_in", "tests/test_colls.py::test_empty", "tests/test_colls.py::test_empty_iter", "tests/test_colls.py::test_empty_quirks", "t...
python -m pytest -q -rA -p no:cacheprovider
I'm aggregating per-shard counters: I have a couple of dozen dictionaries that all share the same ~20 keys and I combine them with `merge_with(sum, *dicts)` in a hot loop (once per request). This used to be essentially free, but now a single merge of 20 small dicts takes on the order of a millisecond, and my batch job ...
funcy.colls.merge_with
0.499708
4.208376
8.421663
perf-pool-swesmith
Suor__funcy.perf_2
Suor/funcy
jyangballin/swesmith.x86_64.suor_1776_funcy.207a7810
4895f919dfd83e24f0334421c5bac104b69d8946
diff --git a/funcy/decorators.py b/funcy/decorators.py index e001629..bc517db 100644 --- a/funcy/decorators.py +++ b/funcy/decorators.py @@ -105,10 +105,7 @@ def get_argnames(func): func = getattr(func, '__original__', None) or unwrap(func) return func.__code__.co_varnames[:func.__code__.co_argcount] -def a...
diff --git b/funcy/decorators.py a/funcy/decorators.py index bc517db..e001629 100644 --- b/funcy/decorators.py +++ a/funcy/decorators.py @@ -105,7 +105,10 @@ def get_argnames(func): func = getattr(func, '__original__', None) or unwrap(func) return func.__code__.co_varnames[:func.__code__.co_argcount] -def a...
import timeit from funcy import decorator @decorator def audit(call): if call.user_id < 0 or call.action == '' or call.retries > 10: raise ValueError('bad call') return call() @audit def handle(user_id, action, payload=None, retries=0, verbose=False, tag='x'): return (user_id, action, retries) ...
[ "tests/test_decorators.py::test_chain_arg_access", "tests/test_decorators.py::test_decorator_access_args", "tests/test_decorators.py::test_decorator_introspection", "tests/test_decorators.py::test_decorator_kw_only_args", "tests/test_decorators.py::test_decorator_no_args", "tests/test_decorators.py::test_...
python -m pytest -q -rA -p no:cacheprovider
I use the `@decorator` helper to write small validation decorators that look up a few of the wrapped function's arguments by name (`call.user_id`, `call.action`, ...). Under load this got surprisingly expensive: a decorated function that does almost no work now costs around 20 microseconds per call instead of a few, so...
funcy.decorators.decorator
0.820393
2.516525
3.067464
perf-pool-swesmith
Suor__funcy.perf_3
Suor/funcy
jyangballin/swesmith.x86_64.suor_1776_funcy.207a7810
4895f919dfd83e24f0334421c5bac104b69d8946
diff --git a/funcy/seqs.py b/funcy/seqs.py index 9a96252..6e3c953 100644 --- a/funcy/seqs.py +++ b/funcy/seqs.py @@ -329,7 +329,8 @@ def group_values(seq): """Takes a sequence of (key, value) pairs and groups values by keys.""" result = defaultdict(list) for key, value in seq: - result[key].append...
diff --git b/funcy/seqs.py a/funcy/seqs.py index 6e3c953..9a96252 100644 --- b/funcy/seqs.py +++ a/funcy/seqs.py @@ -329,8 +329,7 @@ def group_values(seq): """Takes a sequence of (key, value) pairs and groups values by keys.""" result = defaultdict(list) for key, value in seq: - values = result[ke...
import random import timeit from funcy import group_values random.seed(2) KEYS = ['region-%d' % i for i in range(6)] PAIRS = [(random.choice(KEYS), random.random()) for _ in range(3000)] def run(): return group_values(PAIRS) run() N = 1500 times = timeit.repeat("run()", globals=globals(), number=N, repeat=5)...
[ "tests/test_seqs.py::test_butlast", "tests/test_seqs.py::test_cat", "tests/test_seqs.py::test_chunks", "tests/test_seqs.py::test_concat", "tests/test_seqs.py::test_count_by", "tests/test_seqs.py::test_count_by_is_defaultdict", "tests/test_seqs.py::test_count_reps", "tests/test_seqs.py::test_distinct",...
python -m pytest -q -rA -p no:cacheprovider
I group a stream of (region, measurement) pairs by region before aggregating. With a few thousand pairs spread over only a handful of regions, grouping now takes milliseconds per call and dominates my aggregation step — it used to be barely measurable. The slowdown clearly depends on how big the individual groups get: ...
funcy.seqs.group_values
0.382358
3.856041
10.0849
perf-pool-swesmith
andialbrecht__sqlparse.perf_2
andialbrecht/sqlparse
jyangballin/swesmith.x86_64.andialbrecht_1776_sqlparse.e57923b3
d802518f3673051449163fc84fe1455448f79b3b
diff --git a/sqlparse/sql.py b/sqlparse/sql.py index 1037375..6ec2044 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -199,12 +199,12 @@ class TokenList(Token): def get_token_at_offset(self, offset): """Returns the token that is on position offset.""" - idx = 0 - for token in self.fl...
diff --git b/sqlparse/sql.py a/sqlparse/sql.py index 6ec2044..1037375 100644 --- b/sqlparse/sql.py +++ a/sqlparse/sql.py @@ -199,12 +199,12 @@ class TokenList(Token): def get_token_at_offset(self, offset): """Returns the token that is on position offset.""" - tokens = list(self.flatten()) - ...
import timeit import sqlparse sql = ("SELECT c0, c1, c2, c3, c4, c5, c6, c7 " "FROM t1 JOIN t2 ON t1.id = t2.id " "WHERE t1.a = 1 AND t2.b = 2") stmt = sqlparse.parse(sql)[0] offsets = tuple(range(0, len(sql), 11)) def run(): for off in offsets: stmt.get_token_at_offset(off) run() # wa...
[ "tests/test_grouping.py::test_aliased_column_without_as", "tests/test_grouping.py::test_aliased_function_without_as", "tests/test_grouping.py::test_aliased_literal_without_as", "tests/test_grouping.py::test_begin", "tests/test_grouping.py::test_compare_expr[select", "tests/test_grouping.py::test_compariso...
python -m pytest -q -rA -p no:cacheprovider
I built a small SQL editor helper that, for every cursor position in a query, asks the parsed statement which token sits at that character offset (used for tooltips and highlighting). This lookup used to be effectively free, but now it noticeably lags while typing: a single lookup on a modest query with a join and a co...
sqlparse.sql.TokenList.get_token_at_offset
0.861401
6.263802
7.271648
perf-pool-swesmith
andialbrecht__sqlparse.perf_3
andialbrecht/sqlparse
jyangballin/swesmith.x86_64.andialbrecht_1776_sqlparse.e57923b3
d802518f3673051449163fc84fe1455448f79b3b
diff --git a/sqlparse/sql.py b/sqlparse/sql.py index 1037375..f65dc12 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -418,7 +418,10 @@ class Statement(TokenList): Whitespaces and comments at the beginning of the statement are ignored. """ - token = self.token_first(skip_cm=True)...
diff --git b/sqlparse/sql.py a/sqlparse/sql.py index f65dc12..1037375 100644 --- b/sqlparse/sql.py +++ a/sqlparse/sql.py @@ -418,10 +418,7 @@ class Statement(TokenList): Whitespaces and comments at the beginning of the statement are ignored. """ - tokens = [tk for tk in self.tokens - ...
import timeit import sqlparse TEMPLATE = ("SELECT a{0}, b{0}, c{0} FROM t{0} WHERE x{0} = {0} " "UNION SELECT d{0}, e{0}, f{0} FROM u{0} WHERE y{0} = {0}") statements = [sqlparse.parse(TEMPLATE.format(i))[0] for i in range(50)] def run(): for stmt in statements: stmt.get_type() run() # w...
[ "tests/test_grouping.py::test_aliased_column_without_as", "tests/test_grouping.py::test_aliased_function_without_as", "tests/test_grouping.py::test_aliased_literal_without_as", "tests/test_grouping.py::test_begin", "tests/test_grouping.py::test_compare_expr[select", "tests/test_grouping.py::test_compariso...
python -m pytest -q -rA -p no:cacheprovider
Our pipeline parses SQL scripts and then routes each statement based on its type (SELECT vs INSERT vs DDL). Asking a parsed statement for its type has become surprisingly expensive: for a batch of a few dozen already-parsed statements the type lookup alone now dominates the routing step, and it gets worse the longer ea...
sqlparse.sql.Statement.get_type
0.771412
2.911759
3.774584
perf-pool-swesmith
jd__tenacity.perf_0
jd/tenacity
jyangballin/swesmith.x86_64.jd_1776_tenacity.0d40e76f
88214ad37db95e1adc7e780518e9656dac630ab1
diff --git a/tenacity/retry.py b/tenacity/retry.py index 9211631..2d5b633 100644 --- a/tenacity/retry.py +++ b/tenacity/retry.py @@ -269,7 +269,10 @@ class retry_any(retry_base): self.retries = retries def __call__(self, retry_state: "RetryCallState") -> bool: - return any(r(retry_state) for r in...
diff --git b/tenacity/retry.py a/tenacity/retry.py index 2d5b633..9211631 100644 --- b/tenacity/retry.py +++ a/tenacity/retry.py @@ -269,10 +269,7 @@ class retry_any(retry_base): self.retries = retries def __call__(self, retry_state: "RetryCallState") -> bool: - # Evaluate every sub-strategy for ...
import sys import timeit import tenacity class RootError(Exception): pass others = [type(f"OtherError{i}", (Exception,), {}) for i in range(15)] condition = tenacity.retry_any( tenacity.retry_if_exception_type(RootError), *[tenacity.retry_if_exception_type(cls) for cls in others], ) retrying = tenaci...
[ "tests/test_asyncio.py::TestAsyncio::test_attempt_number_is_correct_for_interleaved_coroutines", "tests/test_asyncio.py::TestAsyncio::test_iscoroutinefunction", "tests/test_asyncio.py::TestAsyncio::test_repr", "tests/test_asyncio.py::TestAsyncio::test_retry", "tests/test_asyncio.py::TestAsyncio::test_retry_...
python -m pytest -q -rA -p no:cacheprovider
I combine a bunch of retry predicates with `retry_any(...)` (about 15 of them, mostly exception-type checks for the various error classes our HTTP client can raise) and reuse that combined predicate for every attempt of a very chatty client. Profiling shows that evaluating the combined condition is dominating the retry...
tenacity.retry_any.__call__
0.366022
4.324625
11.815199
perf-pool-swesmith
jd__tenacity.perf_1
jd/tenacity
jyangballin/swesmith.x86_64.jd_1776_tenacity.0d40e76f
88214ad37db95e1adc7e780518e9656dac630ab1
diff --git a/tenacity/retry.py b/tenacity/retry.py index 9211631..028ea0d 100644 --- a/tenacity/retry.py +++ b/tenacity/retry.py @@ -161,10 +161,20 @@ class retry_if_exception_cause_type(retry_base): if retry_state.outcome.failed: exc = retry_state.outcome.exception() - while exc is n...
diff --git b/tenacity/retry.py a/tenacity/retry.py index 028ea0d..9211631 100644 --- b/tenacity/retry.py +++ a/tenacity/retry.py @@ -161,20 +161,10 @@ class retry_if_exception_cause_type(retry_base): if retry_state.outcome.failed: exc = retry_state.outcome.exception() - # Inspect the ...
import sys import timeit import tenacity class TargetError(Exception): pass exc = ValueError("root cause") for i in range(50): wrapper = RuntimeError(f"layer {i}") wrapper.__cause__ = exc exc = wrapper condition = tenacity.retry_if_exception_cause_type(TargetError) retrying = tenacity.Retrying() ...
[ "tests/test_tenacity.py::TestBase::test_callstate_repr", "tests/test_tenacity.py::TestBase::test_retrying_repr", "tests/test_tenacity.py::TestBeforeAfterAttempts::test_after_attempts", "tests/test_tenacity.py::TestBeforeAfterAttempts::test_before_attempts", "tests/test_tenacity.py::TestBeforeAfterAttempts::...
python -m pytest -q -rA -p no:cacheprovider
We use a cause-based retry predicate (`retry_if_exception_cause_type`) in a service where exceptions get re-raised with `raise ... from ...` at each layer, so by the time the top-level retry decision is made the `__cause__` chain is a few dozen entries deep. Checking whether any cause is of the interesting type is far ...
tenacity.retry_if_exception_cause_type.__call__
0.570032
6.022421
10.565066
perf-pool-swesmith
jd__tenacity.perf_2
jd/tenacity
jyangballin/swesmith.x86_64.jd_1776_tenacity.0d40e76f
88214ad37db95e1adc7e780518e9656dac630ab1
diff --git a/tenacity/retry.py b/tenacity/retry.py index 9211631..2fbe4be 100644 --- a/tenacity/retry.py +++ b/tenacity/retry.py @@ -95,7 +95,19 @@ class retry_if_exception_type(retry_if_exception): ] = Exception, ) -> None: self.exception_types = exception_types - super().__init__(lambda ...
diff --git b/tenacity/retry.py a/tenacity/retry.py index 2fbe4be..9211631 100644 --- b/tenacity/retry.py +++ a/tenacity/retry.py @@ -95,19 +95,7 @@ class retry_if_exception_type(retry_if_exception): ] = Exception, ) -> None: self.exception_types = exception_types - - def predicate(e: BaseE...
import sys import timeit import tenacity class LevelA(Exception): pass class LevelB(LevelA): pass class LevelC(LevelB): pass class LevelD(LevelC): pass class LevelE(LevelD): pass class LevelF(LevelE): pass unrelated = tuple(type(f"Unrelated{i}", (Exception,), {}) for i in range(40...
[ "tests/test_asyncio.py::TestAsyncio::test_attempt_number_is_correct_for_interleaved_coroutines", "tests/test_asyncio.py::TestAsyncio::test_iscoroutinefunction", "tests/test_asyncio.py::TestAsyncio::test_repr", "tests/test_asyncio.py::TestAsyncio::test_retry", "tests/test_asyncio.py::TestAsyncio::test_retry_...
python -m pytest -q -rA -p no:cacheprovider
Our retry configuration lists a fairly long tuple of exception classes (around 40 of them, from a couple of client libraries) in `retry_if_exception_type(...)`, and the exception we actually get has a deep class hierarchy. Deciding whether to retry takes tens of microseconds per attempt, which is way more than the rest...
tenacity.retry_if_exception_type
0.426318
2.267028
5.317693
perf-pool-swesmith
jd__tenacity.perf_3
jd/tenacity
jyangballin/swesmith.x86_64.jd_1776_tenacity.0d40e76f
88214ad37db95e1adc7e780518e9656dac630ab1
diff --git a/tenacity/wait.py b/tenacity/wait.py index dc3c850..4f77737 100644 --- a/tenacity/wait.py +++ b/tenacity/wait.py @@ -108,8 +108,13 @@ class wait_chain(wait_base): self.strategies = strategies def __call__(self, retry_state: "RetryCallState") -> float: - wait_func_no = min(max(retry_st...
diff --git b/tenacity/wait.py a/tenacity/wait.py index 4f77737..dc3c850 100644 --- b/tenacity/wait.py +++ a/tenacity/wait.py @@ -108,13 +108,8 @@ class wait_chain(wait_base): self.strategies = strategies def __call__(self, retry_state: "RetryCallState") -> float: - strategies = list(self.strategi...
import timeit import tenacity strategies = ( [tenacity.wait_fixed(1) for _ in range(30)] + [tenacity.wait_fixed(2) for _ in range(30)] + [tenacity.wait_fixed(5) for _ in range(20)] ) chain = tenacity.wait_chain(*strategies) retrying = tenacity.Retrying() state = tenacity.RetryCallState(retry_object=retry...
[ "tests/test_tenacity.py::TestBase::test_callstate_repr", "tests/test_tenacity.py::TestBase::test_retrying_repr", "tests/test_tenacity.py::TestBeforeAfterAttempts::test_after_attempts", "tests/test_tenacity.py::TestBeforeAfterAttempts::test_before_attempts", "tests/test_tenacity.py::TestBeforeAfterAttempts::...
python -m pytest -q -rA -p no:cacheprovider
I configure a long `wait_chain` (built from list comprehensions, so it ends up with ~80 stages describing a detailed backoff schedule) and reuse it across a lot of retried calls. Computing the wait for a given attempt is surprisingly expensive — several microseconds each time — and it gets worse the longer the chain is...
tenacity.wait_chain.__call__
0.226351
1.954642
8.635433
perf-pool-swesmith
hukkin__tomli.perf_0
hukkin/tomli
jyangballin/swesmith.x86_64.hukkin_1776_tomli.443a0c1b
f7058cd4848de25cbf61e27a8bf34298b8aabb81
diff --git a/src/tomli/_parser.py b/src/tomli/_parser.py index 16c76cd..c4da373 100644 --- a/src/tomli/_parser.py +++ b/src/tomli/_parser.py @@ -312,17 +312,28 @@ def skip_until( error_on: frozenset[str], error_on_eof: bool, ) -> Pos: - try: - new_pos = src.index(expect, pos) - except ValueError...
diff --git b/src/tomli/_parser.py a/src/tomli/_parser.py index c4da373..16c76cd 100644 --- b/src/tomli/_parser.py +++ a/src/tomli/_parser.py @@ -312,28 +312,17 @@ def skip_until( error_on: frozenset[str], error_on_eof: bool, ) -> Pos: - src_len = len(src) - expect_len = len(expect) - - # Walk forwar...
import statistics import timeit import tomli BODY = "abcdefghij" * 20 # 200-char literal string bodies lines = [] for i in range(10000): lines.append("key%d = '%s'" % (i, BODY)) doc = "\n".join(lines) + "\n" # warm up once tomli.loads(doc) times = timeit.repeat(lambda: tomli.loads(doc), number=20, repeat=5) p...
[ "tests/test_data.py::TestData::test_invalid", "tests/test_data.py::TestData::test_valid", "tests/test_error.py::TestError::test_deprecated_tomldecodeerror", "tests/test_error.py::TestError::test_invalid_char_quotes", "tests/test_error.py::TestError::test_invalid_parse_float", "tests/test_error.py::TestErr...
python -m pytest -q -rA -p no:cacheprovider
I use tomli to load configuration files that contain a lot of single-quoted literal strings (paths, regexes, license texts) as well as long trailing comments. On a ~2 MB file made mostly of such lines, `tomli.loads` takes several seconds, while a comparable file made of bare numbers parses roughly ten times faster. It ...
tomli.loads
1.146396
7.861737
6.857786
perf-pool-swesmith
hukkin__tomli.perf_1
hukkin/tomli
jyangballin/swesmith.x86_64.hukkin_1776_tomli.443a0c1b
f7058cd4848de25cbf61e27a8bf34298b8aabb81
diff --git a/src/tomli/_parser.py b/src/tomli/_parser.py index 16c76cd..fa1a114 100644 --- a/src/tomli/_parser.py +++ b/src/tomli/_parser.py @@ -208,7 +208,8 @@ class Flags: EXPLICIT_NEST = 1 def __init__(self) -> None: - self._flags: dict[str, dict] = {} + # Flat record of set flags: (key, fl...
diff --git b/src/tomli/_parser.py a/src/tomli/_parser.py index fa1a114..16c76cd 100644 --- b/src/tomli/_parser.py +++ a/src/tomli/_parser.py @@ -208,8 +208,7 @@ class Flags: EXPLICIT_NEST = 1 def __init__(self) -> None: - # Flat record of set flags: (key, flag, recursive) - self._flags: list =...
import statistics import timeit import tomli parts = [] for i in range(600): parts.append( "[table%d]\nalpha = 1\nbeta = 2\ngamma = 3\ndelta = 4\n" % i ) doc = "".join(parts) # warm up once tomli.loads(doc) times = timeit.repeat(lambda: tomli.loads(doc), number=100, repeat=5) print(f"Mean: {statisti...
[ "tests/test_data.py::TestData::test_invalid", "tests/test_data.py::TestData::test_valid", "tests/test_error.py::TestError::test_deprecated_tomldecodeerror", "tests/test_error.py::TestError::test_invalid_char_quotes", "tests/test_error.py::TestError::test_invalid_parse_float", "tests/test_error.py::TestErr...
python -m pytest -q -rA -p no:cacheprovider
We parse a generated TOML manifest that declares a few hundred to a few thousand `[table]` sections, each with a handful of simple key/value pairs. Parsing feels fine for small files, but the time grows much faster than the file size: doubling the number of tables makes `tomli.loads` roughly four times slower, and a fi...
tomli.loads
1.300938
5.392919
4.145409
perf-pool-swesmith
hukkin__tomli.perf_2
hukkin/tomli
jyangballin/swesmith.x86_64.hukkin_1776_tomli.443a0c1b
f7058cd4848de25cbf61e27a8bf34298b8aabb81
diff --git a/src/tomli/_parser.py b/src/tomli/_parser.py index 16c76cd..b1af57d 100644 --- a/src/tomli/_parser.py +++ b/src/tomli/_parser.py @@ -488,7 +488,8 @@ def parse_array(src: str, pos: Pos, parse_float: ParseFloat) -> tuple[Pos, list] return pos + 1, array while True: pos, val = parse_valu...
diff --git b/src/tomli/_parser.py a/src/tomli/_parser.py index b1af57d..16c76cd 100644 --- b/src/tomli/_parser.py +++ a/src/tomli/_parser.py @@ -488,8 +488,7 @@ def parse_array(src: str, pos: Pos, parse_float: ParseFloat) -> tuple[Pos, list] return pos + 1, array while True: pos, val = parse_valu...
import statistics import timeit import tomli doc = "samples = [" + ", ".join(str(i) for i in range(20000)) + "]\n" # warm up once tomli.loads(doc) times = timeit.repeat(lambda: tomli.loads(doc), number=20, repeat=5) print(f"Mean: {statistics.mean(times)}") print(f"Std Dev: {statistics.stdev(times)}")
[ "tests/test_data.py::TestData::test_invalid", "tests/test_data.py::TestData::test_valid", "tests/test_misc.py::TestMiscellaneous::test_deepcopy", "tests/test_misc.py::TestMiscellaneous::test_incorrect_load", "tests/test_misc.py::TestMiscellaneous::test_inline_array_recursion_limit", "tests/test_misc.py::T...
python -m pytest -q -rA -p no:cacheprovider
I store a numeric time series in TOML as one big array, e.g. `samples = [0, 1, 2, ...]` with tens of thousands of entries. Reading it back with `tomli.loads` is surprisingly slow: 20k elements take well over half a second, and 40k elements take about four times that, so the cost clearly grows quadratically with the num...
tomli.loads
0.955699
11.004445
11.514549
perf-pool-swesmith
cool-RR__PySnooper.perf_0
cool-RR/PySnooper
jyangballin/swesmith.x86_64.cool-rr_1776_pysnooper.57472b46
540ae6f570b4fc0f62e732af704fa412c7e9503a
diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index 1b35154..801f2fe 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -58,10 +58,6 @@ def get_path_and_source_from_frame(frame): module_name = globs.get('__name__') file_name = frame.f_code.co_filename cache_key = (module_name, file_na...
diff --git b/pysnooper/tracer.py a/pysnooper/tracer.py index 801f2fe..1b35154 100644 --- b/pysnooper/tracer.py +++ a/pysnooper/tracer.py @@ -58,6 +58,10 @@ def get_path_and_source_from_frame(frame): module_name = globs.get('__name__') file_name = frame.f_code.co_filename cache_key = (module_name, file_na...
import importlib.util import os import sys import tempfile import timeit sys.path.insert(0, os.getcwd()) import pysnooper # noqa: F401 lines = [ 'import pysnooper', '', 'class Sink(object):', ' def write(self, s):', ' pass', '', ] for i in range(3000): lines.append('CONSTANT_%d ...
[ "tests/test_chinese.py::test_chinese", "tests/test_multiple_files/test_multiple_files.py::test_multiple_files", "tests/test_pysnooper.py::test_callable[False]", "tests/test_pysnooper.py::test_callable[True]", "tests/test_pysnooper.py::test_cellvars[False]", "tests/test_pysnooper.py::test_cellvars[True]", ...
python -m pytest -q -rA -p no:cacheprovider
I'm using PySnooper to debug a function that lives in one of our big auto-generated modules (a few thousand lines of constants at the top, then the function I care about). Snooping a function that executes only ~100 lines takes tens of milliseconds per call, which makes it unusable when the snooped function is called i...
pysnooper.snoop
0.385292
4.811184
12.48711
perf-pool-swesmith
cool-RR__PySnooper.perf_1
cool-RR/PySnooper
jyangballin/swesmith.x86_64.cool-rr_1776_pysnooper.57472b46
540ae6f570b4fc0f62e732af704fa412c7e9503a
diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index 1b35154..879b3f8 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -31,13 +31,23 @@ RETURN_OPCODES = { def get_local_reprs(frame, watch=(), custom_repr=(), max_length=None, normalize=False): code = frame.f_code - vars_order = (code.co_v...
diff --git b/pysnooper/tracer.py a/pysnooper/tracer.py index 879b3f8..1b35154 100644 --- b/pysnooper/tracer.py +++ a/pysnooper/tracer.py @@ -31,23 +31,13 @@ RETURN_OPCODES = { def get_local_reprs(frame, watch=(), custom_repr=(), max_length=None, normalize=False): code = frame.f_code + vars_order = (code.co_v...
import importlib.util import os import sys import tempfile import timeit sys.path.insert(0, os.getcwd()) import pysnooper # noqa: F401 lines = [ 'import pysnooper', '', 'class Sink(object):', ' def write(self, s):', ' pass', '', '@pysnooper.snoop(output=Sink(), color=False)', ...
[ "tests/test_chinese.py::test_chinese", "tests/test_pysnooper.py::test_callable[False]", "tests/test_pysnooper.py::test_callable[True]", "tests/test_pysnooper.py::test_cellvars[False]", "tests/test_pysnooper.py::test_cellvars[True]", "tests/test_pysnooper.py::test_class[False]", "tests/test_pysnooper.py:...
python -m pytest -q -rA -p no:cacheprovider
Snooping functions that have a lot of local variables is far slower than I expected. I have a data-preparation function with about forty locals (mostly small ints and strings), and running it under a snoop decorator takes ~50ms per call for a body of only ~100 executed lines, i.e. roughly half a millisecond of tracing ...
pysnooper.snoop
0.909125
4.293559
4.72274
perf-pool-swesmith
cool-RR__PySnooper.perf_2
cool-RR/PySnooper
jyangballin/swesmith.x86_64.cool-rr_1776_pysnooper.57472b46
540ae6f570b4fc0f62e732af704fa412c7e9503a
diff --git a/pysnooper/variables.py b/pysnooper/variables.py index 2229c38..bc6f435 100644 --- a/pysnooper/variables.py +++ b/pysnooper/variables.py @@ -29,7 +29,8 @@ class BaseVariable(pycompat.ABC): def items(self, frame, normalize=False): try: - main_value = eval(self.code, frame.f_globals...
diff --git b/pysnooper/variables.py a/pysnooper/variables.py index bc6f435..2229c38 100644 --- b/pysnooper/variables.py +++ a/pysnooper/variables.py @@ -29,8 +29,7 @@ class BaseVariable(pycompat.ABC): def items(self, frame, normalize=False): try: - main_value = eval(self.source, frame.f_globa...
import timeit import pysnooper class Sink(object): def write(self, s): pass class Holder(object): def __init__(self): self.data = {'alpha': list(range(5)), 'beta': {'x': 1}} self.number = 3 self.name = 'holder' WATCH = tuple( 'holder.data["alpha"][{}] + holder.number *...
[ "tests/test_not_implemented.py::test_rejecting_async_generator_functions", "tests/test_not_implemented.py::test_rejecting_coroutine_functions", "tests/test_pysnooper.py::test_callable[False]", "tests/test_pysnooper.py::test_callable[True]", "tests/test_pysnooper.py::test_cellvars[False]", "tests/test_pysn...
python -m pytest -q -rA -p no:cacheprovider
I snoop a hot function while watching a couple dozen expressions (things like `holder.data["alpha"][2] + holder.number * 3 - len(holder.name)`), and the tracing overhead is enormous: about 0.7ms per traced line, so a function with 25 executed lines takes ~18ms per call. If I drop the watched expressions, the same funct...
pysnooper.snoop
0.452219
2.965375
6.55739
perf-pool-swesmith
cool-RR__PySnooper.perf_3
cool-RR/PySnooper
jyangballin/swesmith.x86_64.cool-rr_1776_pysnooper.57472b46
540ae6f570b4fc0f62e732af704fa412c7e9503a
diff --git a/pysnooper/utils.py b/pysnooper/utils.py index ff9b9e8..6213f65 100644 --- a/pysnooper/utils.py +++ b/pysnooper/utils.py @@ -70,7 +70,11 @@ def get_shortish_repr(item, custom_repr=(), max_length=None, normalize=False): r = repr_function(item) except Exception: r = 'REPR FAILED' - r...
diff --git b/pysnooper/utils.py a/pysnooper/utils.py index 6213f65..ff9b9e8 100644 --- b/pysnooper/utils.py +++ a/pysnooper/utils.py @@ -70,11 +70,7 @@ def get_shortish_repr(item, custom_repr=(), max_length=None, normalize=False): r = repr_function(item) except Exception: r = 'REPR FAILED' - #...
import random import timeit import pysnooper class Sink(object): def write(self, s): pass @pysnooper.snoop(output=Sink(), color=False, max_variable_length=None) def run(text): total = 0 for i in range(5): total += text.count('a', i) return total random.seed(0) alphabet = 'abcdefgh...
[ "tests/test_chinese.py::test_chinese", "tests/test_pysnooper.py::test_callable[False]", "tests/test_pysnooper.py::test_callable[True]", "tests/test_pysnooper.py::test_cellvars[False]", "tests/test_pysnooper.py::test_cellvars[True]", "tests/test_pysnooper.py::test_class[False]", "tests/test_pysnooper.py:...
python -m pytest -q -rA -p no:cacheprovider
When I snoop a function that holds a long text blob in a local variable (a few thousand characters) and pass `max_variable_length=None` because I want to see the whole value, tracing becomes painfully slow — roughly 0.3ms of overhead per traced line, so even a 15-line function costs several milliseconds per call. Shrin...
pysnooper.snoop
0.886596
6.086255
6.864741
perf-pool-swesmith
tkrajina__gpxpy.perf_0
tkrajina/gpxpy
jyangballin/swesmith.x86_64.tkrajina_1776_gpxpy.09fc46b3
a8565e949a735629d09ad30ff5f905238ea0a20d
diff --git a/gpxpy/gpx.py b/gpxpy/gpx.py index 73e2024..95b7a78 100644 --- a/gpxpy/gpx.py +++ b/gpxpy/gpx.py @@ -2453,7 +2453,11 @@ class GPX: distance_from_start += distance - points.append(PointData(point, distance_from_start, track_no, segment_no, point_no)) + ...
diff --git b/gpxpy/gpx.py a/gpxpy/gpx.py index 95b7a78..73e2024 100644 --- b/gpxpy/gpx.py +++ a/gpxpy/gpx.py @@ -2453,11 +2453,7 @@ class GPX: distance_from_start += distance - point_data = PointData(point, distance_from_start, track_no, - ...
import datetime import random import statistics import timeit import gpxpy.gpx as mod_gpx random.seed(42) N_POINTS = 12000 gpx = mod_gpx.GPX() track = mod_gpx.GPXTrack() gpx.tracks.append(track) segment = mod_gpx.GPXTrackSegment() track.segments.append(segment) start = datetime.datetime(2020, 1, 1, 8, 0, 0) lat, l...
[ "test.py::GPXTests::test_10_to_11_conversion", "test.py::GPXTests::test_add_elevation", "test.py::GPXTests::test_add_missing_data_no_intervals", "test.py::GPXTests::test_add_missing_data_one_interval", "test.py::GPXTests::test_add_missing_data_one_interval_and_empty_points_on_start_and_end", "test.py::GPX...
python -m pytest -q -rA -p no:cacheprovider
I load a GPX activity with around 12k track points and then ask the library for the per-point data (point + distance from start + indices) so that I can plot a distance profile. On my machine a single call takes several hundred milliseconds, which is far more than the actual geodesic math should cost — computing all th...
gpxpy.gpx.GPX.get_points_data
0.225044
3.599858
15.996269
perf-pool-swesmith
kayak__pypika.perf_0
kayak/pypika
jyangballin/swesmith.x86_64.kayak_1776_pypika.1c9646f0
6a742f12bfa386994289ec8b75824663d8ee4b15
diff --git a/pypika/queries.py b/pypika/queries.py index 42c7c45..0f646f1 100644 --- a/pypika/queries.py +++ b/pypika/queries.py @@ -1524,8 +1524,8 @@ class QueryBuilder(Selectable, Term): the alias, otherwise the field will be rendered as SQL. """ clauses = [] - selected_aliases = {s....
diff --git b/pypika/queries.py a/pypika/queries.py index 0f646f1..42c7c45 100644 --- b/pypika/queries.py +++ a/pypika/queries.py @@ -1524,8 +1524,8 @@ class QueryBuilder(Selectable, Term): the alias, otherwise the field will be rendered as SQL. """ clauses = [] + selected_aliases = {s....
import timeit import statistics from pypika import Query, Table, Field table = Table("abc") selects = [Field("col%d" % i, table=table).as_("a%d" % i) for i in range(800)] orderbys = [Field("col%d" % i, table=table).as_("z%d" % i) for i in range(800)] query = Query.from_(table).select(*selects).orderby(*orderbys) de...
[ "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", "py...
python -m pytest -q -rA -p no:cacheprovider
We generate reporting SQL where a single SELECT can contain several hundred aliased columns and an equally long ORDER BY list (we sort by many computed columns). Rendering one of those queries to a string takes tens of milliseconds, and since we render thousands of them per report run it dominates our request time. If ...
pypika.queries.QueryBuilder.get_sql (ORDER BY rendering)
0.385222
2.52747
6.561077
perf-pool-swesmith
kayak__pypika.perf_1
kayak/pypika
jyangballin/swesmith.x86_64.kayak_1776_pypika.1c9646f0
6a742f12bfa386994289ec8b75824663d8ee4b15
diff --git a/pypika/queries.py b/pypika/queries.py index 42c7c45..d835f45 100644 --- a/pypika/queries.py +++ b/pypika/queries.py @@ -1492,8 +1492,8 @@ class QueryBuilder(Selectable, Term): otherwise the entire field will be rendered as SQL. """ clauses = [] - selected_aliases = {s.alia...
diff --git b/pypika/queries.py a/pypika/queries.py index d835f45..42c7c45 100644 --- b/pypika/queries.py +++ a/pypika/queries.py @@ -1492,8 +1492,8 @@ class QueryBuilder(Selectable, Term): otherwise the entire field will be rendered as SQL. """ clauses = [] + selected_aliases = {s.alia...
import timeit import statistics from pypika import Query, Table, Field table = Table("abc") selects = [Field("col%d" % i, table=table).as_("a%d" % i) for i in range(800)] groupbys = [Field("col%d" % i, table=table).as_("z%d" % i) for i in range(800)] query = Query.from_(table).select(*selects).groupby(*groupbys) de...
[ "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", "pypika/tests/test_groupby_modifiers.py::RollupTests::...
python -m pytest -q -rA -p no:cacheprovider
We build wide analytical queries programmatically: a few hundred aliased select terms plus a few hundred group-by terms (we group by every dimension column). Calling str() on such a query takes ~50ms, which is surprising for pure string building, and it makes our batch job that emits thousands of queries take minutes. ...
pypika.queries.QueryBuilder.get_sql (GROUP BY rendering)
0.372633
2.441217
6.551262
perf-pool-swesmith
kayak__pypika.perf_2
kayak/pypika
jyangballin/swesmith.x86_64.kayak_1776_pypika.1c9646f0
6a742f12bfa386994289ec8b75824663d8ee4b15
diff --git a/pypika/queries.py b/pypika/queries.py index 42c7c45..09cccb6 100644 --- a/pypika/queries.py +++ b/pypika/queries.py @@ -671,8 +671,8 @@ class _SetOperation(Selectable, Term): the alias, otherwise the field will be rendered as SQL. """ clauses = [] - selected_aliases = {s.a...
diff --git b/pypika/queries.py a/pypika/queries.py index 09cccb6..42c7c45 100644 --- b/pypika/queries.py +++ a/pypika/queries.py @@ -671,8 +671,8 @@ class _SetOperation(Selectable, Term): the alias, otherwise the field will be rendered as SQL. """ clauses = [] + selected_aliases = {s.a...
import timeit import statistics from pypika import Query, Table, Field table = Table("abc") selects = [Field("col%d" % i, table=table).as_("a%d" % i) for i in range(600)] orderbys = [Field("col%d" % i, table=table).as_("z%d" % i) for i in range(600)] q1 = Query.from_(table).select(*selects) q2 = Query.from_(table).se...
[ "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", "py...
python -m pytest -q -rA -p no:cacheprovider
We union two wide queries (each selecting ~600 aliased columns) and then sort the union by a long list of columns. Turning the resulting union into SQL takes far longer than rendering the two sub-queries separately — about ten times longer in our measurements — even though the extra work should just be appending an ORD...
pypika.queries._SetOperation.get_sql (ORDER BY rendering)
0.678552
2.442341
3.599342
perf-pool-swesmith
kayak__pypika.perf_3
kayak/pypika
jyangballin/swesmith.x86_64.kayak_1776_pypika.1c9646f0
6a742f12bfa386994289ec8b75824663d8ee4b15
diff --git a/pypika/queries.py b/pypika/queries.py index 42c7c45..a2c067b 100644 --- a/pypika/queries.py +++ b/pypika/queries.py @@ -1,4 +1,4 @@ -from copy import copy +from copy import copy, deepcopy from functools import reduce from typing import Any, List, Optional, Sequence, Tuple as TypedTuple, Type, Union @@ ...
diff --git b/pypika/queries.py a/pypika/queries.py index a2c067b..42c7c45 100644 --- b/pypika/queries.py +++ a/pypika/queries.py @@ -1,4 +1,4 @@ -from copy import copy, deepcopy +from copy import copy from functools import reduce from typing import Any, List, Optional, Sequence, Tuple as TypedTuple, Type, Union @@ ...
import timeit import statistics from pypika import Query, Table, Field table = Table("abc", schema="my_schema") query = Query.update(table) for i in range(400): query = query.set(Field("col%d" % i, table=table), i) def run(): return query.get_sql() run() N = 250 results = timeit.repeat(run, number=N, rep...
[ "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability"...
python -m pytest -q -rA -p no:cacheprovider
We build wide UPDATE statements: one table and a few hundred assignments in the SET clause (generated from a dict of changed fields). Converting the built query to a SQL string is unexpectedly slow — roughly 15ms for 400 assignments — while an equally large SELECT with the same number of terms renders in a fraction of ...
pypika.queries.QueryBuilder.get_sql (UPDATE ... SET rendering)
0.443598
3.478865
7.842381
perf-pool-swesmith
pyca__pyopenssl.perf_1
pyca/pyopenssl
jyangballin/swesmith.x86_64.pyca_1776_pyopenssl.04766a49
e09c764d14b07dc882175e2f064f7cb25666ff65
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py index 448a19a..74be8d4 100644 --- a/src/OpenSSL/crypto.py +++ b/src/OpenSSL/crypto.py @@ -126,7 +126,11 @@ def _new_mem_buf(buffer: bytes | None = None) -> Any: bio = _lib.BIO_new(_lib.BIO_s_mem()) free = _lib.BIO_free else: - data...
diff --git b/src/OpenSSL/crypto.py a/src/OpenSSL/crypto.py index 74be8d4..448a19a 100644 --- b/src/OpenSSL/crypto.py +++ a/src/OpenSSL/crypto.py @@ -126,11 +126,7 @@ def _new_mem_buf(buffer: bytes | None = None) -> Any: bio = _lib.BIO_new(_lib.BIO_s_mem()) free = _lib.BIO_free else: - # Co...
import timeit import warnings warnings.simplefilter("ignore") from OpenSSL import crypto key = crypto.PKey() key.generate_key(crypto.TYPE_RSA, 2048) cert = crypto.X509() cert.set_version(2) subject = cert.get_subject() subject.C = "US" subject.ST = "California" subject.L = "San Francisco" subject.O = "Example Corpo...
[ "tests/test_crypto.py::TestCRL::test_verify_with_missing_crl", "tests/test_crypto.py::TestCRL::test_verify_with_revoked", "tests/test_crypto.py::TestEllipticCurve::test_a_curve", "tests/test_crypto.py::TestEllipticCurve::test_not_a_curve", "tests/test_crypto.py::TestEllipticCurve::test_repr", "tests/test_...
python -m pytest -q -rA -p no:cacheprovider
I parse a large number of DER certificates coming off the wire (a few thousand per batch, each roughly 2 KB with a subjectAltName holding a few dozen names). Loading them has become surprisingly expensive: each load takes several hundred microseconds, and the time grows linearly with the size of the byte string I pass ...
OpenSSL.crypto.load_certificate
0.289108
1.35248
4.678122
perf-pool-swesmith
pyca__pyopenssl.perf_2
pyca/pyopenssl
jyangballin/swesmith.x86_64.pyca_1776_pyopenssl.04766a49
e09c764d14b07dc882175e2f064f7cb25666ff65
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py index 448a19a..cac546a 100644 --- a/src/OpenSSL/crypto.py +++ b/src/OpenSSL/crypto.py @@ -874,13 +874,18 @@ class X509Extension: } def _subjectAltNameString(self) -> str: - names = _ffi.cast( - "GENERAL_NAMES*", _lib.X509V3_EXT_d2i...
diff --git b/src/OpenSSL/crypto.py a/src/OpenSSL/crypto.py index cac546a..448a19a 100644 --- b/src/OpenSSL/crypto.py +++ a/src/OpenSSL/crypto.py @@ -874,18 +874,13 @@ class X509Extension: } def _subjectAltNameString(self) -> str: - def decode_names() -> Any: - names = _ffi.cast( - ...
import timeit import warnings warnings.simplefilter("ignore") from OpenSSL import crypto san = ",".join("DNS:host%d.example.com" % i for i in range(80)) ext = crypto.X509Extension(b"subjectAltName", False, san.encode("ascii")) str(ext) N = 5000 times = timeit.repeat(lambda: str(ext), number=N, repeat=5) mean = su...
[ "tests/test_crypto.py::TestCRL::test_verify_with_missing_crl", "tests/test_crypto.py::TestCRL::test_verify_with_revoked", "tests/test_crypto.py::TestEllipticCurve::test_a_curve", "tests/test_crypto.py::TestEllipticCurve::test_not_a_curve", "tests/test_crypto.py::TestEllipticCurve::test_repr", "tests/test_...
python -m pytest -q -rA -p no:cacheprovider
I render certificate extensions as text for a diagnostics page, and stringifying a subjectAltName extension that contains many entries has become very slow. With about 80 DNS names in the SAN, converting the extension to a string takes over a millisecond, and if I bump the number of names the cost grows quadratically —...
OpenSSL.crypto.X509Extension.__str__
0.418539
6.663615
15.92113
perf-pool-swesmith
benoitc__gunicorn.perf_0
benoitc/gunicorn
jyangballin/swesmith.x86_64.benoitc_1776_gunicorn.bacbf8aa
32cfc9f9c36eb6dc632f604a57b531bc21b04b50
diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 646d684..beb79af 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -571,8 +571,15 @@ class Arbiter: if len(self.WORKERS) < self.num_workers: self.spawn_workers() - workers = self.WORKERS.items() - workers = so...
diff --git b/gunicorn/arbiter.py a/gunicorn/arbiter.py index beb79af..646d684 100644 --- b/gunicorn/arbiter.py +++ a/gunicorn/arbiter.py @@ -571,15 +571,8 @@ class Arbiter: if len(self.WORKERS) < self.num_workers: self.spawn_workers() - # build the worker list ordered by age, oldest first...
import random import timeit from gunicorn.app.base import BaseApplication from gunicorn.arbiter import Arbiter class DummyApplication(BaseApplication): def init(self, parser, opts, args): pass def load(self): pass def load_config(self): pass class DummyWorker: def __init__...
[ "tests/test_arbiter.py::test_arbiter_calls_worker_exit", "tests/test_arbiter.py::test_arbiter_reap_workers", "tests/test_arbiter.py::test_arbiter_reexec_limit_child", "tests/test_arbiter.py::test_arbiter_reexec_limit_parent", "tests/test_arbiter.py::test_arbiter_reexec_passing_gunicorn_sockets", "tests/te...
python -m pytest -q -rA -p no:cacheprovider
We run gunicorn masters with a fairly high worker count (a few dozen per box) and noticed that the master process burns a surprising amount of CPU just keeping the worker set in shape. Profiling the master loop shows the bookkeeping step that maintains the number of workers is by far the hottest thing, and it gets noti...
gunicorn.arbiter.Arbiter.manage_workers
0.391276
2.522612
6.447139
perf-pool-swesmith
benoitc__gunicorn.perf_1
benoitc/gunicorn
jyangballin/swesmith.x86_64.benoitc_1776_gunicorn.bacbf8aa
32cfc9f9c36eb6dc632f604a57b531bc21b04b50
diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index e34fcd5..f9f3e4d 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -98,7 +98,14 @@ class SafeAtoms(dict): dict.__init__(self) for key, value in atoms.items(): if isinstance(value, str): - self[key]...
diff --git b/gunicorn/glogging.py a/gunicorn/glogging.py index f9f3e4d..e34fcd5 100644 --- b/gunicorn/glogging.py +++ a/gunicorn/glogging.py @@ -98,14 +98,7 @@ class SafeAtoms(dict): dict.__init__(self) for key, value in atoms.items(): if isinstance(value, str): - # escape ...
import timeit from gunicorn.glogging import SafeAtoms atoms = { 'h': '10.0.0.42', 'l': '-', 'u': '-', 't': '[10/Oct/2023:13:55:36 -0700]', 'r': 'GET /api/v2/orders?page=12&per_page=100&sort=created_at HTTP/1.1', 's': '200', 'm': 'GET', 'U': '/api/v2/orders', 'q': 'page=12&per_page=...
[ "tests/test_config.py::test_always_use_configured_logger", "tests/test_config.py::test_app_config", "tests/test_config.py::test_bind_fd", "tests/test_config.py::test_bool_validation", "tests/test_config.py::test_callable_validation", "tests/test_config.py::test_callable_validation_for_string", "tests/te...
python -m pytest -q -rA -p no:cacheprovider
We have a custom access logger that wraps the request atoms before formatting them, and under load the wrapping step alone shows up as a top CPU consumer. Our requests carry a decent number of headers, and some values are long (user agents, referrers with query strings), so the atoms mapping ends up with 40-50 entries ...
gunicorn.glogging.SafeAtoms.__init__
0.374441
5.431162
14.504702
perf-pool-swesmith
alecthomas__voluptuous.perf_0
alecthomas/voluptuous
jyangballin/swesmith.x86_64.alecthomas_1776_voluptuous.a7a55f83
b8b062752cb57db85878170d3ca5e9d4febe7d18
diff --git a/voluptuous/schema_builder.py b/voluptuous/schema_builder.py index cdeb514..32a2fc3 100644 --- a/voluptuous/schema_builder.py +++ b/voluptuous/schema_builder.py @@ -263,21 +263,35 @@ class Schema(object): candidates = list(_iterate_mapping_candidates(_compiled_schema)) - # After we have ...
diff --git b/voluptuous/schema_builder.py a/voluptuous/schema_builder.py index 32a2fc3..cdeb514 100644 --- b/voluptuous/schema_builder.py +++ a/voluptuous/schema_builder.py @@ -263,35 +263,21 @@ class Schema(object): candidates = list(_iterate_mapping_candidates(_compiled_schema)) - # Wildcards such...
import timeit from voluptuous import Schema KEYS = ['field_%03d' % i for i in range(200)] schema = Schema({k: str for k in KEYS}) data = {k: 'value_%s' % k for k in KEYS} # warm up schema(data) results = timeit.repeat(lambda: schema(data), number=2000, repeat=5) mean = sum(results) / len(results) std = (sum((r - me...
[ "voluptuous/tests/tests.py::test_IsDir", "voluptuous/tests/tests.py::test_IsFile", "voluptuous/tests/tests.py::test_PathExists", "voluptuous/tests/tests.py::test_SomeOf_max_validation", "voluptuous/tests/tests.py::test_SomeOf_min_validation", "voluptuous/tests/tests.py::test_SomeOf_on_bounds_assertion", ...
python -m pytest -q -rA -p no:cacheprovider
I use voluptuous to validate configuration payloads that have a couple of hundred literal string keys in the schema (one entry per setting), and I call the compiled schema on every incoming request. Validation of a single 200-key dict takes many milliseconds, which is far more than I expected for what is essentially a ...
voluptuous.Schema.__call__
0.355661
10.943965
30.770763
perf-pool-swesmith
alecthomas__voluptuous.perf_1
alecthomas/voluptuous
jyangballin/swesmith.x86_64.alecthomas_1776_voluptuous.a7a55f83
b8b062752cb57db85878170d3ca5e9d4febe7d18
diff --git a/voluptuous/validators.py b/voluptuous/validators.py index 3f026b1..700653a 100644 --- a/voluptuous/validators.py +++ b/voluptuous/validators.py @@ -921,13 +921,17 @@ class ExactSequence(object): ) -> None: self.validators = validators self.msg = msg + self._kwargs = kwargs ...
diff --git b/voluptuous/validators.py a/voluptuous/validators.py index 700653a..3f026b1 100644 --- b/voluptuous/validators.py +++ a/voluptuous/validators.py @@ -921,17 +921,13 @@ class ExactSequence(object): ) -> None: self.validators = validators self.msg = msg - self._kwargs = kwargs ...
import timeit from voluptuous import Coerce, ExactSequence, Schema schema = Schema([ExactSequence([str, int, Coerce(float), str, int])]) rows = [['name_%d' % i, i, '1.5', 'tag', i * 2] for i in range(200)] # warm up schema(rows) results = timeit.repeat(lambda: schema(rows), number=400, repeat=5) mean = sum(results)...
[ "voluptuous/tests/tests.py::test_IsDir", "voluptuous/tests/tests.py::test_IsFile", "voluptuous/tests/tests.py::test_PathExists", "voluptuous/tests/tests.py::test_SomeOf_max_validation", "voluptuous/tests/tests.py::test_SomeOf_min_validation", "voluptuous/tests/tests.py::test_SomeOf_on_bounds_assertion", ...
python -m pytest -q -rA -p no:cacheprovider
I am validating CSV-like data: each row is a fixed-length list, so my schema is roughly `Schema([ExactSequence([str, int, Coerce(float), str, int])])` and I feed it a few hundred rows at a time. This is surprisingly slow — a 200-row batch takes tens of milliseconds, while validating the same rows with a plain list-of-t...
voluptuous.ExactSequence.__call__
0.233848
1.167084
4.990772
perf-pool-swesmith
alecthomas__voluptuous.perf_2
alecthomas/voluptuous
jyangballin/swesmith.x86_64.alecthomas_1776_voluptuous.a7a55f83
b8b062752cb57db85878170d3ca5e9d4febe7d18
diff --git a/voluptuous/humanize.py b/voluptuous/humanize.py index eabfd02..7f8080e 100644 --- a/voluptuous/humanize.py +++ b/voluptuous/humanize.py @@ -33,12 +33,18 @@ def humanize_error( and MultipleInvalid.__str__ only provides the first error. """ if isinstance(validation_error, MultipleInvalid): - ...
diff --git b/voluptuous/humanize.py a/voluptuous/humanize.py index 7f8080e..eabfd02 100644 --- b/voluptuous/humanize.py +++ a/voluptuous/humanize.py @@ -33,18 +33,12 @@ def humanize_error( and MultipleInvalid.__str__ only provides the first error. """ if isinstance(validation_error, MultipleInvalid): - ...
import timeit from voluptuous import MultipleInvalid, Schema from voluptuous.humanize import humanize_error schema = Schema({str: int}) data = {'key_%04d' % i: 'not-an-int' for i in range(1200)} error = None try: schema(data) except MultipleInvalid as e: error = e # warm up humanize_error(data, error) resu...
[ "voluptuous/tests/tests.py::test_IsDir", "voluptuous/tests/tests.py::test_IsFile", "voluptuous/tests/tests.py::test_PathExists", "voluptuous/tests/tests.py::test_SomeOf_max_validation", "voluptuous/tests/tests.py::test_SomeOf_min_validation", "voluptuous/tests/tests.py::test_SomeOf_on_bounds_assertion", ...
python -m pytest -q -rA -p no:cacheprovider
I validate large user-supplied dictionaries (about a thousand entries) and, when the payload is bad, I turn the resulting MultipleInvalid into a readable report with the humanized error helper. Producing that report takes hundreds of milliseconds, which is much slower than the validation itself, and it gets dramaticall...
voluptuous.humanize.humanize_error
0.327624
7.272664
22.198224
perf-pool-swesmith
alecthomas__voluptuous.perf_3
alecthomas/voluptuous
jyangballin/swesmith.x86_64.alecthomas_1776_voluptuous.a7a55f83
b8b062752cb57db85878170d3ca5e9d4febe7d18
diff --git a/voluptuous/schema_builder.py b/voluptuous/schema_builder.py index cdeb514..d544286 100644 --- a/voluptuous/schema_builder.py +++ b/voluptuous/schema_builder.py @@ -706,17 +706,25 @@ class Schema(object): def key_literal(key): return key.schema if isinstance(key, Marker) else key - ...
diff --git b/voluptuous/schema_builder.py a/voluptuous/schema_builder.py index d544286..cdeb514 100644 --- b/voluptuous/schema_builder.py +++ a/voluptuous/schema_builder.py @@ -706,25 +706,17 @@ class Schema(object): def key_literal(key): return key.schema if isinstance(key, Marker) else key - ...
import timeit from voluptuous import Optional, Required, Schema base = {} for i in range(400): base[Required('base_%03d' % i)] = str extension = {} for i in range(200): extension[Required('base_%03d' % i)] = int for i in range(200): extension[Optional('extra_%03d' % i)] = str schema = Schema(base) # wa...
[ "voluptuous/tests/tests.py::test_IsDir", "voluptuous/tests/tests.py::test_IsFile", "voluptuous/tests/tests.py::test_PathExists", "voluptuous/tests/tests.py::test_SomeOf_max_validation", "voluptuous/tests/tests.py::test_SomeOf_min_validation", "voluptuous/tests/tests.py::test_SomeOf_on_bounds_assertion", ...
python -m pytest -q -rA -p no:cacheprovider
We compose validation schemas at runtime: a large base schema (a few hundred `Required`/`Optional` keys) that gets merged with a per-tenant overlay of similar size using `Schema.extend`. Each merge now takes tens of milliseconds, and it clearly scales badly — going from 200 to 400 keys on each side made it about four t...
voluptuous.Schema.extend
0.770645
3.759825
4.878802
perf-pool-swesmith
getnikola__nikola.perf_1
getnikola/nikola
jyangballin/swesmith.x86_64.getnikola_1776_nikola.0f4c230e
29343c51e7b647d670a614bf32cda756a8801e1c
diff --git a/nikola/utils.py b/nikola/utils.py index 660806f..94c61a7 100644 --- a/nikola/utils.py +++ b/nikola/utils.py @@ -2023,13 +2023,20 @@ def map_metadata(meta, key, config): This uses the METADATA_MAPPING and METADATA_VALUE_MAPPING settings (via ``config``) and modifies the dict in place. """ - f...
diff --git b/nikola/utils.py a/nikola/utils.py index 94c61a7..660806f 100644 --- b/nikola/utils.py +++ a/nikola/utils.py @@ -2023,20 +2023,13 @@ def map_metadata(meta, key, config): This uses the METADATA_MAPPING and METADATA_VALUE_MAPPING settings (via ``config``) and modifies the dict in place. """ - m...
import timeit from nikola.utils import map_metadata MAPPING = {} for i in range(20): MAPPING['foreign_field_{0}'.format(i)] = 'nikola_field_{0}'.format(i) CONFIG = { 'METADATA_MAPPING': {'wordpress': MAPPING}, 'METADATA_VALUE_MAPPING': {'wordpress': { 'nikola_field_0': lambda v: v.strip(), ...
[ "tests/test_command_import_wordpress.py::test_configure_redirections", "tests/test_command_import_wordpress.py::test_create_import[None-additional_args2]", "tests/test_command_import_wordpress.py::test_create_import[only", "tests/test_command_import_wordpress.py::test_create_import[options1-None]", "tests/t...
python -m pytest -q -rA -p no:cacheprovider
I use METADATA_MAPPING (about twenty renames) plus a couple of METADATA_VALUE_MAPPING hooks to import posts from another platform, and each post carries roughly two dozen metadata fields. Applying the mapping to a batch of a hundred posts now takes several milliseconds, which is orders of magnitude more than the handfu...
nikola.utils.map_metadata
0.402619
3.100703
7.701325
perf-pool-swesmith
getnikola__nikola.perf_2
getnikola/nikola
jyangballin/swesmith.x86_64.getnikola_1776_nikola.0f4c230e
29343c51e7b647d670a614bf32cda756a8801e1c
diff --git a/nikola/utils.py b/nikola/utils.py index 660806f..3b7ad47 100644 --- a/nikola/utils.py +++ b/nikola/utils.py @@ -2108,8 +2108,12 @@ class ClassificationTranslationManager(object): else: result = [] for other_lang, classifications in cldata.items(): + # Gathe...
diff --git b/nikola/utils.py a/nikola/utils.py index 3b7ad47..660806f 100644 --- b/nikola/utils.py +++ a/nikola/utils.py @@ -2108,12 +2108,8 @@ class ClassificationTranslationManager(object): else: result = [] for other_lang, classifications in cldata.items(): - # Gathe...
import timeit from nikola.utils import ClassificationTranslationManager LANGS = ['en', 'de', 'fr'] TAGS = ['tag-{0:03d}'.format(i) for i in range(100)] POSTS_PER_CLASSIFICATION_PER_LANGUAGE = { lang: {tag: [] for tag in TAGS} for lang in LANGS } MANAGER = ClassificationTranslationManager() MANAGER.add_defaults(...
[ "tests/integration/test_demo_build.py::test_archive_exists", "tests/integration/test_demo_build.py::test_avoid_double_slash_in_rss", "tests/integration/test_demo_build.py::test_check_files", "tests/integration/test_demo_build.py::test_check_links", "tests/integration/test_demo_build.py::test_gallery_rss", ...
python -m pytest -q -rA -p no:cacheprovider
On a multilingual site (three languages) with a few hundred tags/categories, rendering the taxonomy pages got noticeably slower: looking up which classifications are translations of a given one now costs tens of microseconds each instead of being basically free, and since it is queried once per classification per langu...
nikola.utils.ClassificationTranslationManager.get_translations_as_list
0.236666
3.376066
14.265096
perf-pool-swesmith
getnikola__nikola.perf_3
getnikola/nikola
jyangballin/swesmith.x86_64.getnikola_1776_nikola.0f4c230e
29343c51e7b647d670a614bf32cda756a8801e1c
diff --git a/nikola/plugins/command/auto/__init__.py b/nikola/plugins/command/auto/__init__.py index 7c70221..4a5e643 100644 --- a/nikola/plugins/command/auto/__init__.py +++ b/nikola/plugins/command/auto/__init__.py @@ -574,11 +574,21 @@ class IndexHtmlStaticResource(StaticResource): def transform_html(self, te...
diff --git b/nikola/plugins/command/auto/__init__.py a/nikola/plugins/command/auto/__init__.py index 4a5e643..7c70221 100644 --- b/nikola/plugins/command/auto/__init__.py +++ a/nikola/plugins/command/auto/__init__.py @@ -574,21 +574,11 @@ class IndexHtmlStaticResource(StaticResource): def transform_html(self, te...
import timeit from nikola.plugins.command.auto import IndexHtmlStaticResource class FakeResource: modify_html = True snippet = "<script>document.write('livereload')</script>\n</head>" TRANSFORM = IndexHtmlStaticResource.transform_html RESOURCE = FakeResource() LINES = [ '<!DOCTYPE html>', '<html l...
[ "tests/integration/test_dev_server_serve.py::test_path_omitted[/-/huba/buba-/huba/buba]", "tests/integration/test_dev_server_serve.py::test_path_omitted[/huba/-/huba/-/]", "tests/integration/test_dev_server_serve.py::test_path_omitted[/huba/-/huba/buba-/buba]", "tests/integration/test_dev_server_serve.py::tes...
python -m pytest -q -rA -p no:cacheprovider
When I run the development server with automatic rebuilds and browse pages of my site, serving a single HTML page feels sluggish. My pages are fairly big (a long index page with a few thousand lines of markup, ~300 KB), and the server spends several milliseconds per request just preparing the HTML before sending it, wh...
nikola.plugins.command.auto.IndexHtmlStaticResource.transform_html
0.999363
7.983808
7.988898
perf-pool-swesmith
pyupio__safety.perf_1
pyupio/safety
jyangballin/swesmith.x86_64.pyupio_1776_safety.7654596b
92bb094d46b7b7a2aa3c7aa59f182a159ae953a7
diff --git a/safety/safety.py b/safety/safety.py index 7bb6ad7..47ad16c 100644 --- a/safety/safety.py +++ b/safety/safety.py @@ -686,7 +686,13 @@ def precompute_remediations( secure_vulns_by_user.add(vuln.vulnerability_id) continue - if vuln.package_name in remediations.keys() and str...
diff --git b/safety/safety.py a/safety/safety.py index 47ad16c..7bb6ad7 100644 --- b/safety/safety.py +++ a/safety/safety.py @@ -686,13 +686,7 @@ def precompute_remediations( secure_vulns_by_user.add(vuln.vulnerability_id) continue - analyzed_specs = [(pkg_name, analyzed_spec) - ...
import timeit from collections import defaultdict from types import SimpleNamespace from safety.models import SafetyRequirement from safety.safety import precompute_remediations VULNS = [] for i in range(1200): name = f'pkg{i % 200}' req = SafetyRequirement(f'{name}=={i // 200}.0.0') VULNS.append(SimpleNa...
[ "tests/test_cli.py::TestConfigureLogger::test_configure_logger_debug", "tests/test_cli.py::TestConfigureLogger::test_configure_logger_non_debug", "tests/test_cli.py::TestNetworkTelemetry::test_get_network_telemetry", "tests/test_cli.py::TestNetworkTelemetry::test_get_network_telemetry_access_denied", "tests...
python -m pytest -q -rA -p no:cacheprovider
We scan a monorepo environment with a few hundred packages, and several vulnerabilities per pinned requirement, so the remediation pre-computation gets around 1200 vulnerability objects. That step alone now takes well over a hundred milliseconds per report, and it clearly degrades non-linearly: doubling the number of v...
safety.safety.precompute_remediations
0.469782
7.147936
15.215422
perf-pool-swesmith
scanny__python-pptx.perf_1
scanny/python-pptx
jyangballin/swesmith.x86_64.scanny_1776_python-pptx.278b47b1
55cbb3d03e2776f565b3ff26032c75b3f4872ffc
diff --git a/src/pptx/chart/xmlwriter.py b/src/pptx/chart/xmlwriter.py index 703c53dd..e3d2932a 100644 --- a/src/pptx/chart/xmlwriter.py +++ b/src/pptx/chart/xmlwriter.py @@ -1507,13 +1507,16 @@ class _CategorySeriesXmlWriter(_BaseSeriesXmlWriter): The unicode XML snippet for the ``<c:pt>`` elements containing...
diff --git b/src/pptx/chart/xmlwriter.py a/src/pptx/chart/xmlwriter.py index e3d2932a..703c53dd 100644 --- b/src/pptx/chart/xmlwriter.py +++ a/src/pptx/chart/xmlwriter.py @@ -1507,16 +1507,13 @@ class _CategorySeriesXmlWriter(_BaseSeriesXmlWriter): The unicode XML snippet for the ``<c:pt>`` elements containing...
import timeit from pptx.chart.data import CategoryChartData from pptx.chart.xmlwriter import ChartXmlWriter from pptx.enum.chart import XL_CHART_TYPE CATEGORIES = 80 SERIES = 5 def build_chart_data(): chart_data = CategoryChartData() chart_data.categories = ["Category %03d" % i for i in range(CATEGORIES)] ...
[ "tests/chart/test_category.py::DescribeCategories::it_can_iterate_over_the_categories_it_contains", "tests/chart/test_category.py::DescribeCategories::it_knows_its_depth[depth_fixture0]", "tests/chart/test_category.py::DescribeCategories::it_knows_its_depth[depth_fixture1]", "tests/chart/test_category.py::Des...
python -m pytest -q -rA -p no:cacheprovider
I build a lot of clustered-column charts from tabular reports: about 80 category labels (short strings) and 5 series. Rendering the chart XML for one of these takes ~20 ms, which adds up badly when a report contains dozens of charts. What surprises me is the scaling: doubling the number of categories makes the XML gene...
pptx.chart.xmlwriter.ChartXmlWriter
0.420773
4.934999
11.728411
perf-pool-swesmith
scanny__python-pptx.perf_2
scanny/python-pptx
jyangballin/swesmith.x86_64.scanny_1776_python-pptx.278b47b1
55cbb3d03e2776f565b3ff26032c75b3f4872ffc
diff --git a/src/pptx/chart/xmlwriter.py b/src/pptx/chart/xmlwriter.py index 703c53dd..649e11b8 100644 --- a/src/pptx/chart/xmlwriter.py +++ b/src/pptx/chart/xmlwriter.py @@ -1601,7 +1601,8 @@ class _CategorySeriesXmlWriter(_BaseSeriesXmlWriter): the values for this series. """ xml = "" - ...
diff --git b/src/pptx/chart/xmlwriter.py a/src/pptx/chart/xmlwriter.py index 649e11b8..703c53dd 100644 --- b/src/pptx/chart/xmlwriter.py +++ a/src/pptx/chart/xmlwriter.py @@ -1601,8 +1601,7 @@ class _CategorySeriesXmlWriter(_BaseSeriesXmlWriter): the values for this series. """ xml = "" - ...
import timeit from pptx.chart.data import CategoryChartData from pptx.chart.xmlwriter import ChartXmlWriter from pptx.enum.chart import XL_CHART_TYPE CATEGORIES = 300 SERIES = 3 def build_chart_data(): chart_data = CategoryChartData() chart_data.categories = ["P%04d" % i for i in range(CATEGORIES)] for ...
[ "tests/chart/test_data.py::DescribeBubbleChartData::it_can_add_a_series", "tests/chart/test_data.py::DescribeBubbleDataPoint::it_is_an_XyDataPoint_subclass", "tests/chart/test_data.py::DescribeBubbleDataPoint::it_knows_its_x_y_size_values", "tests/chart/test_data.py::DescribeBubbleSeriesData::it_can_add_a_dat...
python -m pytest -q -rA -p no:cacheprovider
I'm creating line charts from time-series exports: 3 series with 300 points each, string category labels. Generating the chart XML takes around 30 ms per chart, and with several hundred charts in my batch job that's nearly a minute spent just formatting numbers into XML. The cost seems to grow with the square of the nu...
pptx.chart.xmlwriter.ChartXmlWriter
0.532112
4.348313
8.171793
perf-pool-swesmith
scanny__python-pptx.perf_3
scanny/python-pptx
jyangballin/swesmith.x86_64.scanny_1776_python-pptx.278b47b1
55cbb3d03e2776f565b3ff26032c75b3f4872ffc
diff --git a/src/pptx/chart/xmlwriter.py b/src/pptx/chart/xmlwriter.py index 703c53dd..ba286906 100644 --- a/src/pptx/chart/xmlwriter.py +++ b/src/pptx/chart/xmlwriter.py @@ -1487,8 +1487,11 @@ class _CategorySeriesXmlWriter(_BaseSeriesXmlWriter): The unicode XML snippet for the ``<c:pt>`` elements when catego...
diff --git b/src/pptx/chart/xmlwriter.py a/src/pptx/chart/xmlwriter.py index ba286906..703c53dd 100644 --- b/src/pptx/chart/xmlwriter.py +++ a/src/pptx/chart/xmlwriter.py @@ -1487,11 +1487,8 @@ class _CategorySeriesXmlWriter(_BaseSeriesXmlWriter): The unicode XML snippet for the ``<c:pt>`` elements when catego...
import timeit from datetime import date, timedelta from pptx.chart.data import CategoryChartData from pptx.chart.xmlwriter import ChartXmlWriter from pptx.enum.chart import XL_CHART_TYPE DAYS = 60 SERIES = 5 def build_chart_data(): chart_data = CategoryChartData() start = date(2019, 1, 1) chart_data.cat...
[ "tests/chart/test_category.py::DescribeCategories::it_can_iterate_over_the_categories_it_contains", "tests/chart/test_category.py::DescribeCategories::it_knows_its_depth[depth_fixture0]", "tests/chart/test_category.py::DescribeCategories::it_knows_its_depth[depth_fixture1]", "tests/chart/test_category.py::Des...
python -m pytest -q -rA -p no:cacheprovider
When my category labels are `datetime.date` objects (daily buckets) instead of strings, generating the chart XML becomes noticeably slower than the equivalent chart with text labels. With 60 date categories and 5 series, one chart takes around 15 ms, and it degrades quadratically as I extend the date range — 120 days i...
pptx.chart.xmlwriter.ChartXmlWriter
0.822418
13.463015
16.370037
perf-pool-swesmith
pyasn1__pyasn1.perf_0
pyasn1/pyasn1
jyangballin/swesmith.x86_64.pyasn1_1776_pyasn1.0f07d724
f74fc01b17a7624fb8f38a1a9a32b9649826952c
diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py index 9aff5e6..56d751b 100644 --- a/pyasn1/type/univ.py +++ b/pyasn1/type/univ.py @@ -557,8 +557,17 @@ class BitString(base.SimpleAsn1Type): def asBinary(self): """Get |ASN.1| value as a text string of bits. """ - binString = bin(self....
diff --git b/pyasn1/type/univ.py a/pyasn1/type/univ.py index 56d751b..9aff5e6 100644 --- b/pyasn1/type/univ.py +++ a/pyasn1/type/univ.py @@ -557,17 +557,8 @@ class BitString(base.SimpleAsn1Type): def asBinary(self): """Get |ASN.1| value as a text string of bits. """ - # render the value oc...
import statistics import timeit from pyasn1.type import univ HEXDIGITS = '0123456789abcdef' # deterministic ~8192-bit payload hexValue = ''.join(HEXDIGITS[(i * 7 + 3) % 16] for i in range(2048)) bitString = univ.BitString(hexValue=hexValue) # warm up bitString.asBinary() N = 50000 timings = timeit.repeat(lambda:...
[ "tests/codec/ber/test_decoder.py::AnyDecoderTestCase::testByUntagged", "tests/codec/ber/test_decoder.py::AnyDecoderTestCase::testByUntaggedIndefMode", "tests/codec/ber/test_decoder.py::AnyDecoderTestCase::testByUntaggedSubst", "tests/codec/ber/test_decoder.py::AnyDecoderTestCase::testByUntaggedSubstV04", "t...
python -m pytest -q -rA -p no:cacheprovider
I keep BIT STRING objects of a few kilobits around (certificate key usage blobs, bitmap-style flags coming out of a BER decode) and I print them / take their binary text form for logging and diffing. Getting the binary text of a single ~8000 bit value now takes hundreds of microseconds, so logging a few thousand of the...
pyasn1.type.univ.BitString.asBinary
0.28739
9.65884
33.608831
perf-pool-swesmith
pyasn1__pyasn1.perf_1
pyasn1/pyasn1
jyangballin/swesmith.x86_64.pyasn1_1776_pyasn1.0f07d724
f74fc01b17a7624fb8f38a1a9a32b9649826952c
diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py index 9aff5e6..0f3c04c 100644 --- a/pyasn1/type/univ.py +++ b/pyasn1/type/univ.py @@ -619,7 +619,13 @@ class BitString(base.SimpleAsn1Type): value: :class:`bytes` Text string like b'\\\\x01\\\\xff' """ - value = SizedInteger(in...
diff --git b/pyasn1/type/univ.py a/pyasn1/type/univ.py index 0f3c04c..9aff5e6 100644 --- b/pyasn1/type/univ.py +++ a/pyasn1/type/univ.py @@ -619,13 +619,7 @@ class BitString(base.SimpleAsn1Type): value: :class:`bytes` Text string like b'\\\\x01\\\\xff' """ - number = 0 - - f...
import statistics import timeit from pyasn1.type import univ # deterministic 256-byte payload payload = bytes((i * 37 + 11) % 256 for i in range(256)) # warm up univ.BitString.fromOctetString(payload, internalFormat=True) N = 300000 timings = timeit.repeat( lambda: univ.BitString.fromOctetString(payload, inter...
[ "tests/codec/ber/test_decoder.py::AnyDecoderTestCase::testByUntagged", "tests/codec/ber/test_decoder.py::AnyDecoderTestCase::testByUntaggedIndefMode", "tests/codec/ber/test_decoder.py::AnyDecoderTestCase::testByUntaggedSubst", "tests/codec/ber/test_decoder.py::AnyDecoderTestCase::testByUntaggedSubstV04", "t...
python -m pytest -q -rA -p no:cacheprovider
I build BIT STRING values from raw byte payloads (a couple of hundred bytes each, straight out of network frames) in a tight loop, and this conversion has become a bottleneck: a single conversion of a 256-byte payload costs tens of microseconds, so a batch of a few hundred thousand messages takes minutes. Profiling sho...
pyasn1.type.univ.BitString.fromOctetString
0.307693
6.342365
20.612625
perf-pool-swesmith
oauthlib__oauthlib.perf_0
oauthlib/oauthlib
jyangballin/swesmith.x86_64.oauthlib_1776_oauthlib.1fd52536
614b1348ef893b4fa90e76f56df44ee64f5d0222
diff --git a/oauthlib/oauth1/rfc5849/signature.py b/oauthlib/oauth1/rfc5849/signature.py index 8916782..07fd643 100644 --- a/oauthlib/oauth1/rfc5849/signature.py +++ b/oauthlib/oauth1/rfc5849/signature.py @@ -348,7 +348,13 @@ def normalize_parameters(params) -> str: # 2. The parameters are sorted by name, using a...
diff --git b/oauthlib/oauth1/rfc5849/signature.py a/oauthlib/oauth1/rfc5849/signature.py index 07fd643..8916782 100644 --- b/oauthlib/oauth1/rfc5849/signature.py +++ a/oauthlib/oauth1/rfc5849/signature.py @@ -348,13 +348,7 @@ def normalize_parameters(params) -> str: # 2. The parameters are sorted by name, using a...
import random import timeit from oauthlib.oauth1.rfc5849.signature import normalize_parameters random.seed(1234) params = [("p%04d" % i, "value %d with spaces" % random.randrange(1000000)) for i in range(500)] random.shuffle(params) # warm up normalize_parameters(params) results = timeit.repeat(lambda: n...
[ "tests/oauth1/rfc5849/test_client.py::ClientConstructorTests::test_convert_to_unicode_resource_owner", "tests/oauth1/rfc5849/test_client.py::ClientConstructorTests::test_decoding", "tests/oauth1/rfc5849/test_client.py::ClientConstructorTests::test_give_explicit_nonce", "tests/oauth1/rfc5849/test_client.py::Cl...
python -m pytest -q -rA -p no:cacheprovider
We use OAuth1 request signing for a batch API where each request carries several hundred form/query parameters (bulk updates, long filter lists). Computing the signature for one of these requests takes tens of milliseconds, which is way out of proportion to the amount of data involved - signing a request with 5 paramet...
oauthlib.oauth1.rfc5849.signature.normalize_parameters
0.781052
2.789561
3.571545
perf-pool-swesmith
oauthlib__oauthlib.perf_1
oauthlib/oauthlib
jyangballin/swesmith.x86_64.oauthlib_1776_oauthlib.1fd52536
614b1348ef893b4fa90e76f56df44ee64f5d0222
diff --git a/oauthlib/common.py b/oauthlib/common.py index fd9cad0..eb543b5 100644 --- a/oauthlib/common.py +++ b/oauthlib/common.py @@ -425,9 +425,10 @@ class Request: @property def duplicate_params(self): - seen_keys = collections.defaultdict(int) - all_keys = (p[0] - for ...
diff --git b/oauthlib/common.py a/oauthlib/common.py index eb543b5..fd9cad0 100644 --- b/oauthlib/common.py +++ a/oauthlib/common.py @@ -425,10 +425,9 @@ class Request: @property def duplicate_params(self): - all_keys = [p[0] - for p in (self.decoded_body or []) + self.uri_query_pa...
import timeit from oauthlib.common import Request # 400 body parameters, 50 of which are duplicated names body = "&".join("k%d=v%d" % (i % 350, i) for i in range(400)) uri = "https://example.com/resource?a=1&b=2" request = Request(uri, http_method='POST', body=body, headers={'Content-Type': 'applica...
[ "tests/oauth1/rfc5849/endpoints/test_base.py::BaseEndpointTest::test_case_insensitive_headers", "tests/oauth1/rfc5849/endpoints/test_base.py::BaseEndpointTest::test_client_key_check", "tests/oauth1/rfc5849/endpoints/test_base.py::BaseEndpointTest::test_duplicate_params", "tests/oauth1/rfc5849/endpoints/test_b...
python -m pytest -q -rA -p no:cacheprovider
Our provider validates incoming OAuth1 requests, and part of that check looks for repeated parameter names on the request. For normal requests it's fine, but we have endpoints that accept a form body with several hundred fields, and that duplicate-parameter check alone costs a couple of milliseconds per request - it do...
oauthlib.common.Request.duplicate_params
0.811154
17.770651
21.907862
perf-pool-swesmith
oauthlib__oauthlib.perf_2
oauthlib/oauthlib
jyangballin/swesmith.x86_64.oauthlib_1776_oauthlib.1fd52536
614b1348ef893b4fa90e76f56df44ee64f5d0222
diff --git a/oauthlib/oauth1/rfc5849/request_validator.py b/oauthlib/oauth1/rfc5849/request_validator.py index e937aab..3cd6d96 100644 --- a/oauthlib/oauth1/rfc5849/request_validator.py +++ b/oauthlib/oauth1/rfc5849/request_validator.py @@ -179,8 +179,10 @@ class RequestValidator: and is no shorter than lower ...
diff --git b/oauthlib/oauth1/rfc5849/request_validator.py a/oauthlib/oauth1/rfc5849/request_validator.py index 3cd6d96..e937aab 100644 --- b/oauthlib/oauth1/rfc5849/request_validator.py +++ a/oauthlib/oauth1/rfc5849/request_validator.py @@ -179,10 +179,8 @@ class RequestValidator: and is no shorter than lower ...
import random import string import timeit from oauthlib.oauth1.rfc5849.request_validator import RequestValidator random.seed(7) validator = RequestValidator() alphabet = string.ascii_letters + string.digits nonces = [''.join(random.choice(alphabet) for _ in range(25)) for _ in range(50)] def run(): f...
[ "tests/oauth1/rfc5849/endpoints/test_base.py::BaseEndpointTest::test_case_insensitive_headers", "tests/oauth1/rfc5849/endpoints/test_base.py::BaseEndpointTest::test_client_key_check", "tests/oauth1/rfc5849/endpoints/test_base.py::BaseEndpointTest::test_duplicate_params", "tests/oauth1/rfc5849/endpoints/test_b...
python -m pytest -q -rA -p no:cacheprovider
We front a high-traffic OAuth1 resource endpoint, and while profiling request validation I noticed that the simple nonce format check is surprisingly expensive - about 40 microseconds for a 25-character nonce, which is more than some of our database-backed checks. That's odd for what should just be a character-set and ...
oauthlib.oauth1.rfc5849.request_validator.RequestValidator.check_nonce
0.488877
6.177557
12.636209
perf-pool-swesmith
oauthlib__oauthlib.perf_3
oauthlib/oauthlib
jyangballin/swesmith.x86_64.oauthlib_1776_oauthlib.1fd52536
614b1348ef893b4fa90e76f56df44ee64f5d0222
diff --git a/oauthlib/common.py b/oauthlib/common.py index fd9cad0..d3d0e85 100644 --- a/oauthlib/common.py +++ b/oauthlib/common.py @@ -106,13 +106,15 @@ def urldecode(query): any of name-value pairs omits the equals sign. """ # Check if query contains invalid characters - if query and not set(query)...
diff --git b/oauthlib/common.py a/oauthlib/common.py index d3d0e85..fd9cad0 100644 --- b/oauthlib/common.py +++ a/oauthlib/common.py @@ -106,15 +106,13 @@ def urldecode(query): any of name-value pairs omits the equals sign. """ # Check if query contains invalid characters - if query: - for c in...
import timeit from oauthlib.common import urldecode query = "&".join("key%03d=value_%d" % (i, i * 12345) for i in range(400)) # warm up urldecode(query) results = timeit.repeat(lambda: urldecode(query), number=1000, repeat=5) mean = sum(results) / len(results) std = (sum((x - mean) ** 2 for x in results) / len(res...
[ "tests/oauth1/rfc5849/test_signatures.py::SignatureTests::test_base_string_uri", "tests/oauth1/rfc5849/test_signatures.py::SignatureTests::test_collect_parameters", "tests/oauth1/rfc5849/test_signatures.py::SignatureTests::test_hmac_false_positives", "tests/oauth1/rfc5849/test_signatures.py::SignatureTests::t...
python -m pytest -q -rA -p no:cacheprovider
Decoding urlencoded bodies/query strings has become a bottleneck for us. With a realistic body of ~400 parameters (about 8 KB of text) a single decode call takes over 15 ms, whereas Python's own parse_qsl handles the same string in a fraction of a millisecond. It seems most of the time is burned in the validation step ...
oauthlib.common.urldecode
0.45134
14.658992
32.478793
perf-pool-swesmith
marshmallow-code__webargs.perf_0
marshmallow-code/webargs
jyangballin/swesmith.x86_64.marshmallow-code_1776_webargs.dbde72fe
a2917e5d21655a59807ec580b4a385457eadf628
diff --git a/src/webargs/multidictproxy.py b/src/webargs/multidictproxy.py index de9b82b..04fba7d 100644 --- a/src/webargs/multidictproxy.py +++ b/src/webargs/multidictproxy.py @@ -27,7 +27,15 @@ class MultiDictProxy(MutableMapping): ): self.data = multidict self.known_multi_fields = known_multi_...
diff --git b/src/webargs/multidictproxy.py a/src/webargs/multidictproxy.py index 04fba7d..de9b82b 100644 --- b/src/webargs/multidictproxy.py +++ a/src/webargs/multidictproxy.py @@ -27,15 +27,7 @@ class MultiDictProxy(MutableMapping): ): self.data = multidict self.known_multi_fields = known_multi_...
import timeit import marshmallow as ma from webargs import core, fields class DictParser(core.Parser): def load_querystring(self, req, schema): return self._makeproxy(req["query"], schema) argmap = {} for i in range(30): argmap[f"field{i}"] = fields.Str(load_default="x") for i in range(10): ar...
[ "tests/test_core.py::TestPassingSchema::test_parse_does_not_add_missing_values_to_schema_validator", "tests/test_core.py::TestPassingSchema::test_passing_schema_factory_to_parse", "tests/test_core.py::TestPassingSchema::test_passing_schema_to_parse", "tests/test_core.py::TestPassingSchema::test_use_args_can_b...
python -m pytest -q -rA -p no:cacheprovider
We use webargs to parse query strings into fairly wide argument maps (about 40 fields, some of them list fields) and we've noticed that parsing a single request has become surprisingly expensive — around 8x slower than we measured on an older version. Profiling shows the time isn't in marshmallow's field deserializatio...
webargs.core.Parser.parse
0.927855
4.28975
4.623295
perf-pool-swesmith
marshmallow-code__webargs.perf_2
marshmallow-code/webargs
jyangballin/swesmith.x86_64.marshmallow-code_1776_webargs.dbde72fe
a2917e5d21655a59807ec580b4a385457eadf628
diff --git a/src/webargs/pyramidparser.py b/src/webargs/pyramidparser.py index 56c2736..9691549 100644 --- a/src/webargs/pyramidparser.py +++ b/src/webargs/pyramidparser.py @@ -175,12 +175,10 @@ class PyramidParser(core.Parser[Request]): if arg_name is None and not self.USE_ARGS_POSITIONAL: arg_na...
diff --git b/src/webargs/pyramidparser.py a/src/webargs/pyramidparser.py index 9691549..56c2736 100644 --- b/src/webargs/pyramidparser.py +++ a/src/webargs/pyramidparser.py @@ -175,10 +175,12 @@ class PyramidParser(core.Parser[Request]): if arg_name is None and not self.USE_ARGS_POSITIONAL: arg_na...
import timeit from pyramid.request import Request from webargs import fields from webargs.pyramidparser import parser argmap = {f"f{i}": fields.Str(load_default=None) for i in range(40)} req = Request.blank("/?" + "&".join(f"f{i}=value{i}" for i in range(10))) @parser.use_args(argmap, req=req, location="querystri...
[ "tests/test_pyramidparser.py::TestPyramidParser::test_content_type_mismatch[/echo_form-payload1-application/json]", "tests/test_pyramidparser.py::TestPyramidParser::test_content_type_mismatch[/echo_json-{\"name\":", "tests/test_pyramidparser.py::TestPyramidParser::test_empty_json", "tests/test_pyramidparser.p...
python -m pytest -q -rA -p no:cacheprovider
In a Pyramid app we decorate views with webargs' `use_args`, passing a dict of about 40 fields for the query string. Request handling got noticeably slower after upgrading: each decorated view call spends around a millisecond inside webargs even when only a handful of query parameters are present, which is roughly 10x ...
webargs.pyramidparser.PyramidParser.use_args
0.395598
2.180765
5.512585
perf-pool-swesmith
marshmallow-code__webargs.perf_3
marshmallow-code/webargs
jyangballin/swesmith.x86_64.marshmallow-code_1776_webargs.dbde72fe
a2917e5d21655a59807ec580b4a385457eadf628
diff --git a/src/webargs/core.py b/src/webargs/core.py index 44294e9..529c6d6 100644 --- a/src/webargs/core.py +++ b/src/webargs/core.py @@ -582,17 +582,22 @@ class Parser(typing.Generic[Request]): location = location or self.location request_obj = req - # Optimization: If argmap is passed as...
diff --git b/src/webargs/core.py a/src/webargs/core.py index 529c6d6..44294e9 100644 --- b/src/webargs/core.py +++ a/src/webargs/core.py @@ -582,22 +582,17 @@ class Parser(typing.Generic[Request]): location = location or self.location request_obj = req - # normalize a mapping argmap to a plai...
import timeit from webargs import core, fields class DictParser(core.Parser): def load_querystring(self, req, schema): return self._makeproxy(req["query"], schema) parser = DictParser() argmap = {f"f{i}": fields.Str(load_default=None) for i in range(40)} req = {"query": {f"f{i}": f"value{i}" for i in ...
[ "tests/test_bottleparser.py::TestBottleParser::test_content_type_mismatch[/echo_form-payload1-application/json]", "tests/test_bottleparser.py::TestBottleParser::test_content_type_mismatch[/echo_json-{\"name\":", "tests/test_bottleparser.py::TestBottleParser::test_empty_json", "tests/test_bottleparser.py::Test...
python -m pytest -q -rA -p no:cacheprovider
We decorate our handlers with `use_args` and pass a dict of ~40 marshmallow fields for the query string. Calling such a decorated handler now costs about a millisecond of webargs/marshmallow overhead per call, roughly 10x more than before, even though only five query parameters are actually present. When profiling, alm...
webargs.core.Parser.use_args
0.248538
2.023428
8.141311
perf-pool-swesmith
iterative__dvc.perf_2
iterative/dvc
jyangballin/swesmith.x86_64.iterative_1776_dvc.1d6ea681
6cade21fda479f5e1b616ad19b0d25d2ecb19b7d
diff --git a/dvc/output.py b/dvc/output.py index 48acf49..be3431e 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -218,17 +218,19 @@ def merge_file_meta_from_cloud(entry: dict) -> dict: def _serialize_tree_obj_to_files(obj: Tree) -> list[dict[str, Any]]: key = obj.PARAM_RELPATH - return sorted( - ( ...
diff --git b/dvc/output.py a/dvc/output.py index be3431e..48acf49 100644 --- b/dvc/output.py +++ a/dvc/output.py @@ -218,19 +218,17 @@ def merge_file_meta_from_cloud(entry: dict) -> dict: def _serialize_tree_obj_to_files(obj: Tree) -> list[dict[str, Any]]: key = obj.PARAM_RELPATH - files: list[dict[str, Any]...
import hashlib import io import os import statistics import tempfile import timeit from contextlib import redirect_stderr, redirect_stdout os.environ["DVC_NO_ANALYTICS"] = "1" from dvc.output import loadd_from from dvc.repo import Repo from dvc.stage import Stage from dvc_data.hashfile.tree import Tree N_FILES = 800...
[ "tests/func/test_virtual_directory.py::test_partial_checkout_and_update", "tests/func/test_virtual_directory.py::test_virtual_add", "tests/func/test_virtual_directory.py::test_virtual_remove", "tests/func/test_virtual_directory.py::test_virtual_update_dir", "tests/func/test_virtual_directory.py::test_virtua...
python -m pytest -q -rA -p no:cacheprovider
Serializing a directory output that contains a few hundred/thousand files (writing out the per-file entries, e.g. when dumping a lock file or inspecting an output's serialized form) is much slower than I'd expect: for a directory with ~800 files a single dump takes tens of milliseconds, and doing that for several outpu...
dvc.output.Output.dumpd
0.230616
3.07827
13.348024
perf-pool-swesmith
pyutils__line_profiler.perf_0
pyutils/line_profiler
jyangballin/swesmith.x86_64.pyutils_1776_line_profiler.a646bf0f
e4bc513c02bb40d62165fa62e8735d4bd88d26e3
diff --git a/line_profiler/line_profiler.py b/line_profiler/line_profiler.py index 2a71d03..31c0a00 100755 --- a/line_profiler/line_profiler.py +++ b/line_profiler/line_profiler.py @@ -340,36 +340,40 @@ def show_func(filename, start_lineno, func_name, timings, unit, 'percent': 8, } - display = {} - -...
diff --git b/line_profiler/line_profiler.py a/line_profiler/line_profiler.py index 31c0a00..2a71d03 100755 --- b/line_profiler/line_profiler.py +++ a/line_profiler/line_profiler.py @@ -340,40 +340,36 @@ def show_func(filename, start_lineno, func_name, timings, unit, 'percent': 8, } - # Determine the ...
import io import timeit from line_profiler import show_func N_LINES = 200 FILENAME = '<workload-nonexistent-file.py>' timings = [(lineno, 1 + (lineno % 7), float(1000 + (lineno * 37) % 5000)) for lineno in range(1, N_LINES + 1)] def run(): stream = io.StringIO() show_func(FILENAME, 1, 'workload_f...
[ "tests/test_cli.py::test_cli", "tests/test_cli.py::test_version_agreement", "tests/test_complex_case.py::test_complex_example_python_none", "tests/test_complex_case.py::test_varied_complex_invocations", "tests/test_line_profiler.py::test_classmethod_decorator", "tests/test_line_profiler.py::test_enable_di...
python -m pytest -q -rA -p no:cacheprovider
I have a long-running profiling session where a few of my functions are a couple hundred lines long. When I render the per-function report (either through print_stats or by loading the .lprof and showing it), producing the text for a single function with ~200 measured lines takes noticeably long — tens of milliseconds ...
line_profiler.show_func
0.324181
4.490019
13.850344
perf-pool-swesmith
pyutils__line_profiler.perf_1
pyutils/line_profiler
jyangballin/swesmith.x86_64.pyutils_1776_line_profiler.a646bf0f
e4bc513c02bb40d62165fa62e8735d4bd88d26e3
diff --git a/line_profiler/line_profiler.py b/line_profiler/line_profiler.py index 2a71d03..d763146 100755 --- a/line_profiler/line_profiler.py +++ b/line_profiler/line_profiler.py @@ -461,7 +461,21 @@ def show_text(stats, unit, output_unit=None, stream=None, stripzeros=False, if sort: # Order by ascend...
diff --git b/line_profiler/line_profiler.py a/line_profiler/line_profiler.py index d763146..2a71d03 100755 --- b/line_profiler/line_profiler.py +++ a/line_profiler/line_profiler.py @@ -461,21 +461,7 @@ def show_text(stats, unit, output_unit=None, stream=None, stripzeros=False, if sort: # Order by ascend...
import io import timeit from line_profiler import show_text N_FUNCS = 600 N_LINES = 150 stats = {} for f in range(N_FUNCS): key = ('/tmp/workload_module_%d.py' % f, 10, 'func_%d' % f) stats[key] = [(10 + i, 1 + (i % 5), float((f * 7 + i * 13) % 1000) + 1.0) for i in range(N_LINES)] def ru...
[ "tests/test_cli.py::test_cli", "tests/test_cli.py::test_version_agreement", "tests/test_explicit_profile.py::test_explicit_profile_with_cmdline", "tests/test_explicit_profile.py::test_explicit_profile_with_duplicate_functions", "tests/test_explicit_profile.py::test_explicit_profile_with_environ_off", "tes...
python -m pytest -q -rA -p no:cacheprovider
I profile a fairly large application, so my stats file contains several hundred profiled functions, each with on the order of a hundred measured lines. When I ask for a summary sorted by total time (no per-line details), it takes well over a hundred milliseconds per report, and if I regenerate the summary repeatedly (e...
line_profiler.show_text
0.419202
3.423092
8.165724
perf-pool-swesmith
pyutils__line_profiler.perf_2
pyutils/line_profiler
jyangballin/swesmith.x86_64.pyutils_1776_line_profiler.a646bf0f
e4bc513c02bb40d62165fa62e8735d4bd88d26e3
diff --git a/line_profiler/autoprofile/ast_tree_profiler.py b/line_profiler/autoprofile/ast_tree_profiler.py index fa7f289..215d2cf 100644 --- a/line_profiler/autoprofile/ast_tree_profiler.py +++ b/line_profiler/autoprofile/ast_tree_profiler.py @@ -127,8 +127,18 @@ class AstTreeProfiler: abstract synta...
diff --git b/line_profiler/autoprofile/ast_tree_profiler.py a/line_profiler/autoprofile/ast_tree_profiler.py index 215d2cf..fa7f289 100644 --- b/line_profiler/autoprofile/ast_tree_profiler.py +++ a/line_profiler/autoprofile/ast_tree_profiler.py @@ -127,18 +127,8 @@ class AstTreeProfiler: abstract synta...
import ast import timeit from line_profiler.autoprofile.ast_tree_profiler import AstTreeProfiler N = 4000 SRC = '\n'.join('import mod_%d' % i for i in range(N)) MAPPING = {i: 'mod_%d' % i for i in range(N)} profiler = AstTreeProfiler('workload_script.py', ['mod_%d' % i for i in range(N)], ...
[ "tests/test_autoprofile.py::test_autoprofile_module", "tests/test_autoprofile.py::test_autoprofile_module_list", "tests/test_autoprofile.py::test_autoprofile_module_with_prof_imports", "tests/test_autoprofile.py::test_autoprofile_script_with_module", "tests/test_autoprofile.py::test_autoprofile_script_with_...
python -m pytest -q -rA -p no:cacheprovider
I use the autoprofile machinery on a generated driver script that imports a few thousand modules of our code base (one import per line) and asks for all of them to be profiled. Instrumenting the parsed script — inserting the profiling registrations for the matched imports — takes around half a second, which is much mor...
line_profiler.autoprofile.ast_tree_profiler.AstTreeProfiler._profile_ast_tree
1.021307
4.403665
4.311793
perf-pool-swesmith
pyutils__line_profiler.perf_3
pyutils/line_profiler
jyangballin/swesmith.x86_64.pyutils_1776_line_profiler.a646bf0f
e4bc513c02bb40d62165fa62e8735d4bd88d26e3
diff --git a/line_profiler/autoprofile/util_static.py b/line_profiler/autoprofile/util_static.py index 843e101..5a944f5 100644 --- a/line_profiler/autoprofile/util_static.py +++ b/line_profiler/autoprofile/util_static.py @@ -104,9 +104,13 @@ def _parse_static_node_value(node): elif isinstance(node, ast.Str): ...
diff --git b/line_profiler/autoprofile/util_static.py a/line_profiler/autoprofile/util_static.py index 5a944f5..843e101 100644 --- b/line_profiler/autoprofile/util_static.py +++ a/line_profiler/autoprofile/util_static.py @@ -104,13 +104,9 @@ def _parse_static_node_value(node): elif isinstance(node, ast.Str): ...
import os import tempfile import timeit from line_profiler.autoprofile.util_static import _static_parse N = 15000 tmpdir = tempfile.mkdtemp() fpath = os.path.join(tmpdir, 'workload_static.py') with open(fpath, 'w') as file: file.write('a = [\n') for i in range(N): file.write(" 'entry_%06d',\n" % i)...
[ "tests/test_autoprofile.py::test_autoprofile_module", "tests/test_autoprofile.py::test_autoprofile_module_list", "tests/test_autoprofile.py::test_autoprofile_module_with_prof_imports", "tests/test_autoprofile.py::test_autoprofile_script_with_module", "tests/test_autoprofile.py::test_autoprofile_script_with_...
python -m pytest -q -rA -p no:cacheprovider
We resolve module paths for a large monorepo, and part of that reads a generated python file which contains one big list literal of module locations (about 15k string entries). Statically extracting that constant from the file takes close to a second, while simply parsing the same file with the ast module takes only a ...
line_profiler.autoprofile.util_static._static_parse
0.414809
3.78992
9.13655
perf-pool-swesmith
cknd__stackprinter.perf_0
cknd/stackprinter
jyangballin/swesmith.x86_64.cknd_1776_stackprinter.219fcc52
60ab1766145487cbfb0d7c2fab2f5f1045c8de5b
diff --git a/stackprinter/source_inspection.py b/stackprinter/source_inspection.py index 63bc52c..94bbd2a 100644 --- a/stackprinter/source_inspection.py +++ b/stackprinter/source_inspection.py @@ -68,13 +68,11 @@ def annotate(source_lines, line_offset=0, lineno=0, max_line=2**15): max_line_relative = min(len(sourc...
diff --git b/stackprinter/source_inspection.py a/stackprinter/source_inspection.py index 94bbd2a..63bc52c 100644 --- b/stackprinter/source_inspection.py +++ a/stackprinter/source_inspection.py @@ -68,11 +68,13 @@ def annotate(source_lines, line_offset=0, lineno=0, max_line=2**15): max_line_relative = min(len(sourc...
import os import timeit import stackprinter from stackprinter.source_inspection import annotate path = os.path.join(os.path.dirname(stackprinter.__file__), 'frame_formatting.py') with open(path) as f: source_lines = f.readlines() def run(): return annotate(source_lines, 1, 100) run() # warmup res = time...
[ "tests/test_formatting.py::test_exception_formatting", "tests/test_formatting.py::test_frame_formatting", "tests/test_formatting.py::test_none_tuple_formatting", "tests/test_formatting.py::test_none_value_formatting", "tests/test_frame_inspection.py::test_frameinfo", "tests/test_source_inspection.py::test...
python -m pytest -q -rA -p no:cacheprovider
I use stackprinter to render tracebacks in a logging handler, and the frames that come from our bigger modules (a few hundred lines of code each) have become noticeably expensive to render. Profiling my app shows that most of the time isn't spent in Python's tokenizer at all, but in stackprinter's own source annotation...
stackprinter.source_inspection.annotate
2.075905
12.096757
5.82722
perf-pool-swesmith
cknd__stackprinter.perf_1
cknd/stackprinter
jyangballin/swesmith.x86_64.cknd_1776_stackprinter.219fcc52
60ab1766145487cbfb0d7c2fab2f5f1045c8de5b
diff --git a/stackprinter/extraction.py b/stackprinter/extraction.py index 42ee4ec..987c3ac 100644 --- a/stackprinter/extraction.py +++ b/stackprinter/extraction.py @@ -157,10 +157,14 @@ def get_vars(names, loc, glob, suppressed_vars): def lookup(name, scopeA, scopeB): basename, *attr_path = name.split('.') - ...
diff --git b/stackprinter/extraction.py a/stackprinter/extraction.py index 987c3ac..42ee4ec 100644 --- b/stackprinter/extraction.py +++ a/stackprinter/extraction.py @@ -157,14 +157,10 @@ def get_vars(names, loc, glob, suppressed_vars): def lookup(name, scopeA, scopeB): basename, *attr_path = name.split('.') - -...
import sys import timeit import stackprinter globals().update({"_pad_%d" % i: i for i in range(100000)}) def make_report(): v01 = 1 v02 = 2 v03 = 3 v04 = 4 v05 = 5 v06 = 6 v07 = 7 v08 = 8 v09 = 9 v10 = 10 v11 = 11 v12 = 12 v13 = 13 v14 = 14 v15 = 15 v1...
[ "tests/test_formatting.py::test_exception_formatting", "tests/test_formatting.py::test_frame_formatting", "tests/test_formatting.py::test_none_tuple_formatting", "tests/test_formatting.py::test_none_value_formatting", "tests/test_frame_inspection.py::test_frameinfo" ]
python -m pytest -q -rA -p no:cacheprovider
We call stackprinter.format() on the current stack frame from inside a long-running data processing script. That script's module namespace is huge (we populate tens of thousands of module-level entries from a config/lookup table at startup), and formatting a stack there takes around a tenth of a second per call, which ...
stackprinter.format
0.264667
16.243375
61.372981
perf-pool-swesmith
cknd__stackprinter.perf_2
cknd/stackprinter
jyangballin/swesmith.x86_64.cknd_1776_stackprinter.219fcc52
60ab1766145487cbfb0d7c2fab2f5f1045c8de5b
diff --git a/stackprinter/prettyprinting.py b/stackprinter/prettyprinting.py index 6e17f97..cd24e8a 100644 --- a/stackprinter/prettyprinting.py +++ b/stackprinter/prettyprinting.py @@ -103,16 +103,14 @@ def format_dict(value, truncation, max_depth, depth): val_str = '...' else: vstrs = [] - ...
diff --git b/stackprinter/prettyprinting.py a/stackprinter/prettyprinting.py index cd24e8a..6e17f97 100644 --- b/stackprinter/prettyprinting.py +++ a/stackprinter/prettyprinting.py @@ -103,14 +103,16 @@ def format_dict(value, truncation, max_depth, depth): val_str = '...' else: vstrs = [] + ...
import timeit from stackprinter.prettyprinting import format_value payload = {"key_%05d" % i: ("v%04d" % i) * 16 for i in range(3000)} def run(): return format_value(payload, truncation=1000000, wrap=0) run() # warmup res = timeit.repeat(run, number=60, repeat=5) mean = sum(res) / len(res) std = (sum((x - m...
[ "tests/test_formatting.py::test_exception_formatting", "tests/test_formatting.py::test_frame_formatting", "tests/test_formatting.py::test_none_tuple_formatting", "tests/test_formatting.py::test_none_value_formatting" ]
python -m pytest -q -rA -p no:cacheprovider
I'm using stackprinter's pretty printer to dump largish dictionaries into our logs (a few thousand keys, generous truncation limit so we keep most of the content). Rendering one of those dicts takes several hundred milliseconds, which is far more than the cost of repr-ing the individual keys and values put together. Sm...
stackprinter.prettyprinting.format_value
0.492468
3.75285
7.620499
perf-pool-swesmith
seatgeek__thefuzz.perf_0
seatgeek/thefuzz
jyangballin/swesmith.x86_64.seatgeek_1776_thefuzz.8a05a3ee
4dc2e6df6d273b98386d4e3e9423b2afbaff6c50
diff --git a/thefuzz/utils.py b/thefuzz/utils.py index bcda741..8b0e378 100644 --- a/thefuzz/utils.py +++ b/thefuzz/utils.py @@ -1,10 +1,17 @@ from rapidfuzz.utils import default_process as _default_process -translation_table = {i: None for i in range(128, 256)} # ascii dammit! - def ascii_only(s): - return s...
diff --git b/thefuzz/utils.py a/thefuzz/utils.py index 8b0e378..bcda741 100644 --- b/thefuzz/utils.py +++ a/thefuzz/utils.py @@ -1,17 +1,10 @@ from rapidfuzz.utils import default_process as _default_process +translation_table = {i: None for i in range(128, 256)} # ascii dammit! -def ascii_only(s): - """ - R...
import random import statistics import timeit from thefuzz import utils random.seed(20240115) LETTERS = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ-,." ACCENTS = "\u00e1\u00e9\u00ed\u00f3\u00fa\u00e7\u00e3\u00fc\u00f1\u00c1" strings = [] for _ in range(2000): chars = [random.choice(LETTERS) for _ in ...
[ "test_thefuzz.py::ProcessTest::testEmptyStrings", "test_thefuzz.py::ProcessTest::testGetBestChoice1", "test_thefuzz.py::ProcessTest::testGetBestChoice2", "test_thefuzz.py::ProcessTest::testGetBestChoice3", "test_thefuzz.py::ProcessTest::testGetBestChoice4", "test_thefuzz.py::ProcessTest::testIssue57", "...
python -m pytest -q -rA -p no:cacheprovider
I normalize a large batch of product/team names before matching them, calling the library's string preprocessing helper with `force_ascii=True` on each name (names are short, ~30 characters, and some contain accented characters like "Cães" or "Ça"). For a couple hundred thousand names this takes several seconds, which ...
thefuzz.utils.full_process
0.500775
1.987746
3.969341
perf-pool-swesmith
cloudpipe__cloudpickle.perf_0
cloudpipe/cloudpickle
jyangballin/swesmith.x86_64.cloudpipe_1776_cloudpickle.6220b0ce
80bda140bba2658613ff09ea407744e5ca279200
diff --git a/cloudpickle/cloudpickle.py b/cloudpickle/cloudpickle.py index 8c50ba1..43d0c99 100644 --- a/cloudpickle/cloudpickle.py +++ b/cloudpickle/cloudpickle.py @@ -304,25 +304,21 @@ def _lookup_module_and_qualname(obj, name=None): def _extract_code_globals(co): """Find all globals names read or written to ...
diff --git b/cloudpickle/cloudpickle.py a/cloudpickle/cloudpickle.py index 43d0c99..8c50ba1 100644 --- b/cloudpickle/cloudpickle.py +++ a/cloudpickle/cloudpickle.py @@ -304,21 +304,25 @@ def _lookup_module_and_qualname(obj, name=None): def _extract_code_globals(co): """Find all globals names read or written to ...
import statistics import timeit import cloudpickle src_lines = ["def make():", " def big(x):", " total = 0"] for i in range(100): src_lines.append(f" total += g{i}(x) + C{i}") src_lines.append(" def helper(y):") for i in range(50): src_lines.append(f" y = y + h{i}") src_line...
[ "tests/test_backward_compat.py::test_complex_class", "tests/test_backward_compat.py::test_complex_function", "tests/test_backward_compat.py::test_dynamic_module", "tests/test_backward_compat.py::test_nested_function", "tests/test_backward_compat.py::test_simple_class", "tests/test_backward_compat.py::test...
python -m pytest -q -rA -p no:cacheprovider
I use cloudpickle to ship the same locally-defined worker function to a pool of processes, so `cloudpickle.dumps(func)` is called thousands of times on the exact same function object. The function is not huge, just a couple hundred lines with a nested helper, but each serialization takes on the order of a millisecond, ...
cloudpickle.dumps
0.511572
11.820209
23.105657
perf-pool-swesmith
cloudpipe__cloudpickle.perf_1
cloudpipe/cloudpickle
jyangballin/swesmith.x86_64.cloudpipe_1776_cloudpickle.6220b0ce
80bda140bba2658613ff09ea407744e5ca279200
diff --git a/cloudpickle/cloudpickle.py b/cloudpickle/cloudpickle.py index 8c50ba1..70223ee 100644 --- a/cloudpickle/cloudpickle.py +++ b/cloudpickle/cloudpickle.py @@ -414,14 +414,17 @@ def _extract_class_dict(cls): # See the inline comment in _class_setstate for details. clsdict = {"".join(k): cls.__dict__[...
diff --git b/cloudpickle/cloudpickle.py a/cloudpickle/cloudpickle.py index 70223ee..8c50ba1 100644 --- b/cloudpickle/cloudpickle.py +++ a/cloudpickle/cloudpickle.py @@ -414,17 +414,14 @@ def _extract_class_dict(cls): # See the inline comment in _class_setstate for details. clsdict = {"".join(k): cls.__dict__[...
import statistics import timeit import cloudpickle Base = type("Base", (object,), {f"b{i}": i for i in range(800)}) attrs = {f"a{i}": i for i in range(800)} Big = type("Big", (Base,), attrs) cloudpickle.dumps(Big) N = 400 times = timeit.repeat(lambda: cloudpickle.dumps(Big), number=N, repeat=5) print(f"Mean: {stati...
[ "tests/test_backward_compat.py::test_complex_class", "tests/test_backward_compat.py::test_complex_function", "tests/test_backward_compat.py::test_dynamic_module", "tests/test_backward_compat.py::test_nested_function", "tests/test_backward_compat.py::test_simple_class", "tests/test_backward_compat.py::test...
python -m pytest -q -rA -p no:cacheprovider
We generate configuration classes dynamically at runtime (via `type(...)`) with several hundred class-level attributes, and they inherit from another generated base class that also carries many attributes. Sending one of these classes with `cloudpickle.dumps` takes around 15-20 ms, which is way out of proportion with t...
cloudpickle.dumps
0.603602
22.213309
36.801232
perf-pool-swesmith