GithubHelp home page GithubHelp logo

mapix / py-demandimport Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bwesterb/py-demandimport

0.0 2.0 0.0 35 KB

Lazy import python modules for low start-up time. (Taken from mercurial.)

License: GNU General Public License v2.0

Python 100.00%

py-demandimport's Introduction

demandimport

Delays loading of modules until they are actually used. Perfect for Python apps that need to be snappy like command-line utils. Source-code derived from mercurial.

To enable, write

import demandimport; demandimport.enable()

Imports of the following form will be delayed

import a, b.c
import a.b as c
from a import b, c # a will be loaded immediately, though

These imports with not be delayed

from a import *
b = __import__(a)

Delayed loading will confuse some third-party modules. In that case you can disable the delay for just that module. For example

demandimport.ignore('Crypto.PublicKey._fastmath')

There are also versions that can be used with with

with demandimport.enabled():
   # do something
   with demandimport.disabled():
      import troublesome.module
   with demandimport.ignored('test'):
      import other.troublemaker

Installation

To install demandimport, simply run:

pip install demandimport

Attribution

Matt Mackall <[email protected]> is the original author of the module in Mercurial on which this module is based. Bas Westerbaan <[email protected]> maintains it now.

py-demandimport's People

Contributors

bwesterb avatar poke1024 avatar tbabej avatar

Watchers

James Cloos avatar mapix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.