GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Generation of verbose assertion error with large bytearrays extremely slow · Issue #7206 · pytest-dev/pytest

Generation of verbose assertion error with large bytearrays extremely slow #7206

New issue
Copy link
New issue
Copy link
Open
Open
Generation of verbose assertion error with large bytearrays extremely slow#7206
Copy link
Labels
topic: rewriterelated to the assertion rewrite mechanismtype: performanceperformance or memory problem/improvement

Description

@risicle
risicle
opened on May 9, 2020
Issue body actions

pytest 5.2.4, python 3.7 linux

try this:

def test_foo():
    assert b"\x00"*0xffff + b"\x01" == bytearray(0 for _ in range(0x10000))

pytest <...> -v will spend basically forever generating that error.

Activity

  1. asottile commented on May 10, 2020

    @asottile
    asottile
    on May 10, 2020
    Member
    More actions

    I'm not sure there's much pytest can do here -- by asking for -verbose it produces a pretty-printed output (and most of the time is spent building that many-many-many line bytestring/array)

    here's a snapshot of a profile of a smaller bytestring (0xfff vs 0x1000):

    (the profiling left out a few nodes, but the explosion comes from a single call to difflib.ndiff)

    (profile was generated using this procedure)

  2. risicle commented on May 10, 2020

    @risicle
    risicle
    on May 10, 2020
    Author
    More actions

    Interesting analysis - my only other datapoint is that doing:

    >>> str(bytearray(0 for _ in range(0x10000)))

    is very fast, as is

    >>> from pprint import pprint
    >>> pprint(bytearray(0 for _ in range(0x10000)))
  3. asottile commented on May 10, 2020

    @asottile
    asottile
    on May 10, 2020
    Member
    More actions

    neither of those parts are the slow part -- it's the ndiff

  4. risicle commented on May 10, 2020

    @risicle
    risicle
    on May 10, 2020
    Author
    More actions

    Ah sorry looking at the wrong bit of the diagram.

    Possibly it can't helped then 🤷 . I'm surprised I haven't run into this before, really.

  5. Zac-HD
    added
    type: performanceperformance or memory problem/improvement
    topic: rewriterelated to the assertion rewrite mechanism
    on May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: rewriterelated to the assertion rewrite mechanismtype: performanceperformance or memory problem/improvement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.