Lazy import cache - Utilities

Skip to content
Back to top
View this page
Edit this page

# Lazy import cache

sage.misc.lazy_import_cache.get_cache_file()

  Return the canonical filename for caching names of lazily imported modules.

  EXAMPLES:

  Sage

      sage: from sage.misc.lazy_import_cache import get_cache_file
      sage: get_cache_file()
      '...-lazy_import_cache.pickle'
      sage: get_cache_file().startswith(DOT_SAGE)
      True
      sage: 'cache' in get_cache_file()
      True

  Python

      >>> from sage.all import *
      >>> from sage.misc.lazy_import_cache import get_cache_file
      >>> get_cache_file()
      '...-lazy_import_cache.pickle'
      >>> get_cache_file().startswith(DOT_SAGE)
      True
      >>> 'cache' in get_cache_file()
      True

  It should not matter whether DOT_SAGE ends with a slash:

  Sage

      sage: OLD = DOT_SAGE
      sage: sage.misc.lazy_import_cache.DOT_SAGE = '/tmp'
      sage: get_cache_file().startswith('/tmp/')
      True
      sage: sage.misc.lazy_import_cache.DOT_SAGE = OLD

  [Python]

      >>> from sage.all import *
      >>> OLD = DOT_SAGE
      >>> sage.misc.lazy_import_cache.DOT_SAGE = '/tmp'
      >>> get_cache_file().startswith('/tmp/')
      True
      >>> sage.misc.lazy_import_cache.DOT_SAGE = OLD