diff --git a/qpageview/backgroundjob.py b/qpageview/backgroundjob.py index 6c8768d..378da8f 100644 --- a/qpageview/backgroundjob.py +++ b/qpageview/backgroundjob.py @@ -105,6 +105,8 @@ class SingleRun: old one finishes. """ + __slots__ = ("_job") + def __init__(self): self._job = None diff --git a/qpageview/cache.py b/qpageview/cache.py index 9e7411e..955bbc0 100644 --- a/qpageview/cache.py +++ b/qpageview/cache.py @@ -28,6 +28,8 @@ class ImageEntry: + __slots__ = ("image", "bcount", "time") + def __init__(self, image): self.image = image self.bcount = image.sizeInBytes() diff --git a/qpageview/link.py b/qpageview/link.py index 334a07c..54e6697 100644 --- a/qpageview/link.py +++ b/qpageview/link.py @@ -40,21 +40,16 @@ class Link: - fileName = "" - isExternal = False - targetPage = -1 - url = "" - tooltip = "" - area = Area(0, 0, 0, 0) + __slots__ = ( + "fileName", "isExternal", "targetPage", "url", "tooltip", "area") def __init__(self, left, top, right, bottom, url=None, tooltip=None): + self.fileName = "" self.area = Area(left, top, right, bottom) - if url: - self.url = url - if "://" in url: - self.isExternal = True - if tooltip: - self.tooltip = tooltip + self.url = url or "" + self.isExternal = ("://" in self.url) + self.tooltip = tooltip or "" + self.targetPage = -1 def rect(self): """Return the area attribute as a QRectF().""" diff --git a/qpageview/pdf.py b/qpageview/pdf.py index d94f737..ac0c9f9 100644 --- a/qpageview/pdf.py +++ b/qpageview/pdf.py @@ -51,6 +51,8 @@ class Link(link.Link): """A link that encapsulates QPdfLinkModel data.""" + __slots__ = ("_targetPage", "_url") + def __init__(self, linkobj, index, pointSize): self._targetPage = linkobj.data(index, QPdfLinkModel.Role.Page.value) self._url = linkobj.data(index, diff --git a/qpageview/rectangles.py b/qpageview/rectangles.py index ad835c4..38b7894 100644 --- a/qpageview/rectangles.py +++ b/qpageview/rectangles.py @@ -51,6 +51,8 @@ class Rectangles: once. x should be < x2 and y should be < y2. """ + __slots__ = ("_items", "_index") + def __init__(self, objects=None): """Initializes the Rectangles object. diff --git a/qpageview/util.py b/qpageview/util.py index 26ecd21..fb54142 100644 --- a/qpageview/util.py +++ b/qpageview/util.py @@ -80,6 +80,8 @@ def rect(self): class MapToPage: """Simple class wrapping a QTransform to map rect and point to page coordinates.""" + __slots__ = ("t") + def __init__(self, transform): self.t = transform