Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 698
    • Issues 698
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 16
    • Merge requests 16
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

In order to prepare the next update of Heptapod based on Gitlab 16.0. The instance will be unavailable on 2023-10-06 between 19:00 and 23:00 UTC+2

  • PyPyPyPy
  • pypypypy
  • Issues
  • #3598
Closed
Open
Issue created Nov 20, 2021 by Oliver Margetts@olliemathDeveloper

Slow function call with float and None

I'm having issues with an unusually slow function call. Unfortunately, I can't make the example any smaller than this:

eq = lambda a, b: a == b
# SQL-style null handling
le = lambda a, b: a is not None and a <= b

def select(data, comparator, value):
    return [d for d in data if comparator(d["field"], value)]


data = [{"field": 0.1}, {"field": None}] * 1000000

select(data, eq, None)
select(data, le, 0)

The first filtering operation here takes 0.1s - the second one 94s!

This showed up when I updated the le function from the JS-like lambda a, b: (a or 0) <= b to the SQL-like lambda a, b: a is not None and a <= b. The former is still fast, the latter very slow (cpython speeds are around 0.2s).

comparator.py

Edited Nov 20, 2021 by Oliver Margetts
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking