Jonkman Microblog
  • Login
Show Navigation
  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

Conversation

Notices

  1. clacke (clacke@social.heldscal.la)'s status on Thursday, 07-Dec-2017 04:20:31 EST clacke clacke
    I had a discussion with a colleague whether it's ok to put a Python import deep in a function, in a conditional.

    He explained that pkg_resources takes 300 ms to load. It basically examines your whole sys.path on import. Pretty annoying when all you want to use it for is just to resolve a path relative to your egg.

    So ok, *that* import you can put deep in your function. Otherwise I prefer them all to be at the top and pretend they're declarative.

    Looked around and found this still-open issue from last year. Potentially it takes over a second to import, depending on what's on your sys.path and whether your eggs are zipped, etc:

    https://github.com/pypa/setuptools/issues/510

    > [re: importing pygments]

    > with pkg_resources, 244 ms
    > without pkg_resources, 2.65 ms

    > So just by importing pkg_resources, the slowdown is ~100x. In wall clock time, I have consistently tested the pkg_resources overhead to be at least 150 - 200 ms. This makes pkg_resoucres (sic!) unusable in command line utilities that require fast start up times.
    In conversation Thursday, 07-Dec-2017 04:20:31 EST from social.heldscal.la permalink

    Attachments

    1. Avoid full path enumeration on import of setuptools or pkg_resources? · Issue #510 · pypa/setuptools
      from GitHub
      Originally reported by: konstantint (Bitbucket: konstantint, GitHub: konstantint) At the moment on my machine, it takes about 1.28 seconds to do a bare import pkg_resources, 1.47 seconds to do a b...
    1. ay (ayy@gs.smuglo.li)'s status on Thursday, 07-Dec-2017 04:25:16 EST ay ay
      in reply to
      @clacke And tensorflow with gpu support takes multiple seconds to get going.
      In conversation Thursday, 07-Dec-2017 04:25:16 EST from gs.smuglo.li permalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

Jonkman Microblog is a social network, courtesy of SOBAC Microcomputer Services. It runs on GNU social, version 1.2.0-beta5, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All Jonkman Microblog content and data are available under the Creative Commons Attribution 3.0 license.

Switch to desktop site layout.