Content-Length: 273490 | pFad | http://github.com/fastplotlib/fastplotlib/issues/472

EA use of weakref.proxy · Issue #472 · fastplotlib/fastplotlib · GitHub
Skip to content

use of weakref.proxy #472

Closed
Closed
@kushalkolar

Description

@kushalkolar

I figured it's useful to have this in an issue and publicly as well.

We return weakref.proxy objects to the real Graphic objects so that jupyter doesn't accumulate references when the user uses references to the Graphic.

Almar's description:

The problem is that it may confuse the user (it shows “proxy” in the repr) and it results in a rather unconventional memory management system.

I’ve looked into at least changing the repr, but this is not possible. We’ve discussed the reasons underlying the choice, coming mostly down to event handlers holding onto objects. This is a tricky problem, and there is not a simply solution that will make it go away.

We’ve concluded that the current solution does the job. Since these proxy objects look a lot like the real objects, the burden on the user is not too bad. And if the approach is changed in the future, this will most likely not affect users code.

On the longer term, I think it might be worth looking into a way to clear handlers. This should also be done in pygfx’ world objects. Then when a plot is cleared, it can also clear/destroy all graphics objects within.

I just wanted to add, I think the one issue with proxies is that they are not hashable, so they cannot be used as dict keys.

Anyways, not something we will work on now, but #467 helps make this all cleaner internally.

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









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/fastplotlib/fastplotlib/issues/472

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy