()
Enable Cython speedups

    The shapely.speedups module contains performance enhancements written in C.
    They are automaticaly installed when Python has access to a compiler and
    GEOS development headers during installation, and are enabled by default.

    You can check if speedups are installed with the `available` attribute, and
    check if they have been enabled with the `enabled` attribute.

    >>> from shapely import speedups
    >>> speedups.available
    True
    >>> speedups.enable()
    >>> speedups.enabled
    True
Enable Cython speedups
Enable Cython speedups
def enable():
    """Enable Cython speedups

    The shapely.speedups module contains performance enhancements written in C.
    They are automaticaly installed when Python has access to a compiler and
    GEOS development headers during installation, and are enabled by default.

    You can check if speedups are installed with the `available` attribute, and
    check if they have been enabled with the `enabled` attribute.

    >>> from shapely import speedups
    >>> speedups.available
    True
    >>> speedups.enable()
    >>> speedups.enabled
    True
    """
    if not available:
        warnings.warn("shapely.speedups not available", RuntimeWarning)
        return

    if _orig:
        return

    _orig['CoordinateSequence.ctypes'] = coords.CoordinateSequence.ctypes
    coords.CoordinateSequence.ctypes = property(_speedups.coordseq_ctypes)

    _orig['CoordinateSequence.__iter__'] = coords.CoordinateSequence.__iter__
    coords.CoordinateSequence.__iter__ = method_wrapper(
        _speedups.coordseq_iter)

    _orig['geos_linestring_from_py'] = linestring.geos_linestring_from_py
    linestring.geos_linestring_from_py = _speedups.geos_linestring_from_py

    _orig['geos_linearring_from_py'] = polygon.geos_linearring_from_py
    polygon.geos_linearring_from_py = _speedups.geos_linearring_from_py

    _orig['affine_transform'] = shapely.affinity.affine_transform

    # copy docstring from original function
    def affine_transform(geom, matrix):
        return _speedups.affine_transform(geom, matrix)
    affine_transform.__doc__ = shapely.affinity.affine_transform.__doc__
    shapely.affinity.affine_transform = affine_transform

    global enabled
    enabled = True
def enable ( ) : if not available : warnings . warn ( "shapely.speedups not available" , RuntimeWarning ) return if _orig : return _orig [ 'CoordinateSequence.ctypes' ] = coords . CoordinateSequence . ctypes coords . CoordinateSequence . ctypes = property ( _speedups . coordseq_ctypes ) _orig [ 'CoordinateSequence.__iter__' ] = coords . CoordinateSequence . __iter__ coords . CoordinateSequence . __iter__ = method_wrapper ( _speedups . coordseq_iter ) _orig [ 'geos_linestring_from_py' ] = linestring . geos_linestring_from_py linestring . geos_linestring_from_py = _speedups . geos_linestring_from_py _orig [ 'geos_linearring_from_py' ] = polygon . geos_linearring_from_py polygon . geos_linearring_from_py = _speedups . geos_linearring_from_py _orig [ 'affine_transform' ] = shapely . affinity . affine_transform # copy docstring from original function def affine_transform ( geom , matrix ) : return _speedups . affine_transform ( geom , matrix ) affine_transform . __doc__ = shapely . affinity . affine_transform . __doc__ shapely . affinity . affine_transform = affine_transform global enabled enabled = True