Skip to content

PythonEngine.Initialize slow #598

Closed
Closed

Description

@goerch

Environment

  • Pythonnet version: 2.3.0
  • Python version: 3.6
  • Operating System: Windows 7

Details

When embedding Python in an ASP.NET MVC 5 web application, PythonEngine.Initialize needs a couple of seconds to eagerly load the names of around 50 module namespaces in ModuleObject.LoadNames. If I replace the implementation of LoadNames with a NOP, time spent in PythonEngine.Initialize drops to below 100 ms and the web application still seems to work.

Activity

  1. dmitriyse commented on Jan 15, 2018

    @dmitriyse
    Contributor

    We already have PR for that problem. See #528

    Also try to build python.net from the branch https://github.com/pythonnet/pythonnet/tree/featured
    This branch contains muptiple not yet merged fixes to the master branch.

  2. goerch commented on Jan 15, 2018

    @goerch
    Author

    I don't fully understand the idea of eager initialization of the cache in ModuleObject.LoadNames when other members of ModuleObject use lazy caching. At least in my use case (using only a couple of methods of the 50+ module namespaces) this seems to be a bad tradeoff.

    Are there any benchmarks to justify this design?

  3. goerch commented on Jan 15, 2018

    @goerch
    Author

    Just tested the branch https://github.com/pythonnet/pythonnet/tree/featured. Response time is down to 200 ms with eager initialization of 50+ module namespaces. Thanks for your help!

  4. pierce-martin commented on Apr 25, 2018

    @pierce-martin

    @dmitriyse When will this fix be incorporated into a release? The branch https://github.com/pythonnet/pythonnet/tree/featured seems to work great, but it doesn't appear that master has these changes. Thanks.

  5. den-run-ai commented on Nov 14, 2018

    @den-run-ai
    Contributor

    this is now in master branch: #723

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions