Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tf-lazy-loader

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tf-lazy-loader

Lazy loading of Python modules, based on TensorFlow's LazyLoader util.

  • 0.1.1
  • PyPI
  • Socket score

Maintainers
1

tf-lazy-loader

Installation

pip install tf-lazy-loader

Usage

from tf_lazy_loader import dynamic_import

# Lazily import the "os" module
os = dynamic_import("os")

# Trigger the actual import by referencing a name in the "os" module:
print(os.environ)

Conditionally switching between lazy and eager imports

You can set the lazy arg of the dynamic_import function to False to eagerly import the given module. This can be useful if you only want to perform lazy imports based on a flag.

For example, if you have a Django project and you only want to enable lazy imports when in DEBUG mode, and do imports eagerly in production, you would do something like this:

from django.conf import settings

DEBUG = settings.DEBUG

os = dynamic_import("os", lazy=DEBUG)

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc