Not sure how GNOME's preview feature is written, but macOS QuickLook plugins are written in C, C++, or Objective-C and the plugins included with the OS leverage OpenCL (or maybe Metal now) to accelerate rendering of previews, which is part of why it's so fast.