Skip to content

Pymel loads slow

both sugestions made no time diff for me in maya

forum suggestions

The bulk of the work is happening when PyMel is initializing a bunch of mel scripts.
Skip by setting the PYMEL_SKIP_MEL_INIT environment variable to any value.

To skip initializing plugins, you can set skip_initial_plugins=true in the pymel.conf file

pymel core

when importing pymel.core as pm for the first time, it freezes maya for a few seconds

it takes a while to load, because it scans all the loaded plugins, and then wraps any provided commands with a PyMel version.

workaround

  • The best way to speed that process up would be to unload any plugins you’re not actually making use of.

pymel all

import pymel.all operation instead of just an import pymel.core can be substantially longer. As it is generating all the various Node classes upfront.

source

chat GPT suggestions

ncalls  tottime  percall  cumtime  percall filename:lineno(function))
1    0.001    0.001    2.154    2.154 ...pymel\core\__init__.py:1(<module>)
47    1.109    0.024    1.109    0.024 {built-in method builtins.compile}
53    0.001    0.000    0.932    0.018 <frozen importlib._bootstrap_external>:950(get_code)
22/16    0.000    0.000    0.904    0.056 {built-in method builtins.__import__}
  • compile: Takes up over 1 second—a sign that lots of Python files are being parsed and converted to bytecode on the fly.
  • _installCallbacks and _pluginLoaded: Nearly a full second between them—this is likely PyMEL wiring itself into Maya’s plugin and event system.
  • loadApiCache via factories.py: Roughly half a second—this loads cached bindings and type data, which can be optimized.

If you’re looking to shave this down, a few possible directions:

  1. Set PYMEL_SKIP_MEL_INIT=1 before import (as you’ve started to explore). It skips some MEL-based bootstrapping.
  2. Precompile your .py files to .pyc, especially in PyMEL’s site-packages path, to avoid repeated compilation.
  3. Profile deeper with call graphs: Tools like or SnakeViz can turn cProfile dumps into flame graphs that show what calls what—and how deeply.

If you want, I can help you:

  • Dump this to a .prof file
  • Visualize the full call stack
  • Patch PyMEL’s import to isolate just the expensive bits