diff --git a/src/PIL/features.py b/src/PIL/features.py index 13908c4eb..9f4735aee 100644 --- a/src/PIL/features.py +++ b/src/PIL/features.py @@ -128,6 +128,7 @@ features = { "libjpeg_turbo": ("PIL._imaging", "HAVE_LIBJPEGTURBO", "libjpeg_turbo_version"), "libimagequant": ("PIL._imaging", "HAVE_LIBIMAGEQUANT", "imagequant_version"), "xcb": ("PIL._imaging", "HAVE_XCB", None), + "acceleration": ("PIL._imaging", "acceleration", "acceleration"), } @@ -267,6 +268,7 @@ def pilinfo(out: IO[str] | None = None, supported_formats: bool = True) -> None: for name, feature in [ ("pil", "PIL CORE"), + ("acceleration", "Acceleration"), ("tkinter", "TKINTER"), ("freetype2", "FREETYPE2"), ("littlecms2", "LITTLECMS2"), @@ -291,7 +293,7 @@ def pilinfo(out: IO[str] | None = None, supported_formats: bool = True) -> None: if v is None: v = version(name) if v is not None: - version_static = name in ("pil", "jpg") + version_static = name in ("pil", "jpg", "acceleration") if name == "littlecms2": # this check is also in src/_imagingcms.c:setup_module() version_static = tuple(int(x) for x in v.split(".")) < (2, 7) diff --git a/src/_imaging.c b/src/_imaging.c index 07d9a64cc..84c1d55c3 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -4407,6 +4407,19 @@ setup_module(PyObject *m) { Py_INCREF(have_xcb); PyModule_AddObject(m, "HAVE_XCB", have_xcb); +#ifdef __AVX2__ + PyModule_AddStringConstant(m, "acceleration", "avx2"); +#elif defined(__SSE4__) + PyModule_AddStringConstant(m, "acceleration", "sse4"); +#elif defined(__SSE2__) + PyModule_AddStringConstant(m, "acceleration", "sse2"); +#elif defined(__NEON__) + PyModule_AddStringConstant(m, "acceleration", "neon"); +#else + Py_INCREF(Py_False); + PyModule_AddObject(m, "acceleration", Py_False); +#endif + PyObject *pillow_version = PyUnicode_FromString(version); PyDict_SetItemString( d, "PILLOW_VERSION", pillow_version ? pillow_version : Py_None