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 — probably get rid of `CollectionIndexer` and `CollectionFeature` in favor of numpy arrays for graphic collections · Issue #214 · fastplotlib/fastplotlib

probably get rid of CollectionIndexer and CollectionFeature in favor of numpy arrays for graphic collections #214

New issue
Copy link
New issue
Copy link
Closed
#511
Closed
probably get rid of CollectionIndexer and CollectionFeature in favor of numpy arrays for graphic collections#214
#511
Copy link

Description

@kushalkolar
kushalkolar
opened on Jun 6, 2023
Issue body actions

Right now CollectionIndexer and CollectionFeature are used for fancy indexing of Graphics in a GraphicCollection, such as LineCollection. However I have found that this indexing, since we're using lists and for loops a lot, becomes very slow with thousands of world objects.

# very slow, 16 seconds to change 1,000
 for g in contours[ixs_visible].graphics:
     if not g.visible:
         g.visible = True
        
 for g in contours[ixs_hide].graphics:
     if g.visible:
         g.visible = False

However if we just use a numpy array of graphics instead of a tuple then it is MUCH faster:

# very fast, 10 ms to change 1,000 on an RX 470
for g in contours.graphics[ixs_visible]:
    if not g.visible:
        g.visible = True
    
for g in contours.graphics[ixs_hide]:
    if g.visible:
        g.visible = False

We can set the array as read-only by setting the writeable flag: https://numpy.org/doc/stable/reference/generated/numpy.ndarray.flags.html#numpy.ndarray.flags

Could create a new class that uses numpy array of Graphics to parse feature changes etc., basically have CollectionIndexer use the numpy array of graphics.

Activity

  1. kushalkolar commented on Jun 16, 2023

    @kushalkolar
    kushalkolar
    on Jun 16, 2023
    MemberAuthor
    More actions

    So it seems like keeping CollectionIndexer is fine if we use a numpy array for graphics

    Fast:

    t1 = time()
    line_stack[::2].colors = "magenta"
    print(time() - t1)

    But then this is still slow:

    t1 = time()
    line_stack[::2].colors[::2] = "cyan"
    print(time() - t1)
  2. kushalkolar
    closed this as completedin #511on Jun 16, 2024
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.