Global Context

If you have a single-threaded application that generates many objects, enabling the use of the global context can provide performance enhancements.

Warning

The global context is not thread safe.

Warning

The global context maintains a connection to the database through the duration of each python session and is closed once the program terminates.

How to enable:

pyproj.set_use_global_context

pyproj.set_use_global_context(active=None)

New in version 3.0.0.

Activates the usage of the global context. Using this option can enhance the performance of initializing objects in single-threaded applications.

Warning

The global context is not thread safe.

Warning

The global context maintains a connection to the database through the duration of each python session and is closed once the program terminates.

Note

To modify network settings see: PROJ Network Settings.

Parameters

active (bool, optional) – If True, it activates the use of the global context. If False, the use of the global context is deactivated. If None, it uses the environment variable PYPROJ_GLOBAL_CONTEXT and defaults to False if it is not found. The default is None.