Skip to content

Replace use of renderer._uid by weakref. #9070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions doc/api/api_changes/2017-06-03-ES_unique_renderer.rst

This file was deleted.

12 changes: 0 additions & 12 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from functools import partial
import importlib
import io
import itertools
import os
import sys
import time
Expand Down Expand Up @@ -101,12 +100,6 @@
}


# Used to ensure that caching based on renderer id() is unique without being as
# expensive as a real UUID. 0 is used for renderers that don't derive from
# here, so start at 1.
_unique_renderer_id = itertools.count(1)


def register_backend(format, backend, description=None):
"""
Register a backend for saving to a given file format.
Expand Down Expand Up @@ -277,12 +270,7 @@ class RendererBase(object):

"""
def __init__(self):
# A lightweight id for unique-ification purposes. Along with id(self),
# the combination should be unique enough to use as part of a cache key.
self._uid = next(_unique_renderer_id)

self._texmanager = None

self._text2path = textpath.TextToPath()

def open_group(self, s, gid=None):
Expand Down
4 changes: 0 additions & 4 deletions lib/matplotlib/backends/backend_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import six

import matplotlib.backend_bases
from matplotlib.backends.backend_agg import RendererAgg
from matplotlib.tight_bbox import process_figure_for_rasterizing

Expand Down Expand Up @@ -50,9 +49,6 @@ def __init__(self, figure, width, height, dpi, vector_renderer,
if raster_renderer_class is None:
raster_renderer_class = RendererAgg

# See matplotlib.backend_bases.RendererBase._uid.
self._uid = next(matplotlib.backend_bases._unique_renderer_id)

self._raster_renderer_class = raster_renderer_class
self._width = width
self._height = height
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import math
import warnings
import weakref

import contextlib

Expand Down Expand Up @@ -180,7 +181,6 @@ class Text(Artist):
Handle storing and drawing of text in window or data coordinates.
"""
zorder = 3

_cached = maxdict(50)

def __repr__(self):
Expand Down Expand Up @@ -912,7 +912,7 @@ def get_prop_tup(self, renderer=None):
self._verticalalignment, self._horizontalalignment,
hash(self._fontproperties),
self._rotation, self._rotation_mode,
self.figure.dpi, id(renderer), getattr(renderer, '_uid', 0),
self.figure.dpi, weakref.ref(renderer),
self._linespacing
)

Expand Down