Skip to content
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

Improve the import time. #775

Merged
merged 1 commit into from
Feb 8, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Improve TileSource class repr ([#765](../../pull/765))
- Improve frame slider response with base quads ([#771](../../pull/771))
- Default to nearest-neighbor scaling in lossless image conversion ([#772](../../pull/772))
- Improve the import time ([#775](../../pull/775))

### Bug Fixes
- The tile iterator could return excess tiles with overlap ([#773](../../pull/773))
Expand Down
4 changes: 3 additions & 1 deletion large_image/cache_util/memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import time

import cachetools
import pylibmc

from .. import config

Expand All @@ -28,6 +27,9 @@ class MemCache(cachetools.Cache):

def __init__(self, url='127.0.0.1', username=None, password=None,
getsizeof=None, mustBeAvailable=False):
global pylibmc
import pylibmc

super().__init__(0, getsizeof=getsizeof)
if isinstance(url, str):
url = [url]
Expand Down
5 changes: 4 additions & 1 deletion large_image/tilesource/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from operator import attrgetter

import numpy
import palettable
import PIL
import PIL.Image
import PIL.ImageColor
Expand Down Expand Up @@ -449,6 +448,8 @@ def getPaletteColors(value):
above.
:returns: a numpy array of RGBA value on the scale of [0-255].
"""
import palettable

palette = None
if isinstance(value, (tuple, list)):
palette = value
Expand Down Expand Up @@ -524,6 +525,8 @@ def getAvailableNamedPalettes(includeColors=True, reduced=False):
colors.
:returns: a list of names.
"""
import palettable

palettes = set()
if includeColors:
palettes |= set(PIL.ImageColor.colormap.keys())
Expand Down