code: def __init__(self) -> None:
      if _POLARS_ARCH != "x86-64":
          raise SystemError("CPUID is only available for x86")
  
      if _IS_WINDOWS:
          if _IS_64BIT:
              # VirtualAlloc seems to fail under some weird
              # circumstances when ctypes.windll.kernel32 is
              # used under 64 bit Python. CDLL fixes this.
              self.win = ctypes.CDLL("kernel32.dll")
              opc = _WINDOWS_64_OPC
          else:
              # Here ctypes.windll.kernel32 is needed to get the
              # right DLL. Otherwise it will fail when running
              # 32 bit Python on 64 bit Windows.
              self.win = ctypes.windll.kernel32  # type: ignore[attr-defined]
              opc = _CDECL_32_OPC
      else:
          opc = _POSIX_64_OPC if _IS_64BIT else _CDECL_32_OPC
  
      size = len(opc)
      code = (ctypes.c_ubyte * size)(*opc)
  
      if _IS_WINDOWS:
          self.win.VirtualAlloc.restype = c_void_p
          self.win.VirtualAlloc.argtypes = [
              ctypes.c_void_p,
              ctypes.c_size_t,
              ctypes.c_ulong,
              ctypes.c_ulong,
          ]
          self.addr = self.win.VirtualAlloc(
              None,
              size,
              _MEM_COMMIT | _MEM_RESERVE,
              _PAGE_EXECUTE_READWRITE,
          )
          if not self.addr:
              raise MemoryError(
                  "could not allocate memory for CPUID check"
              )
          ctypes.memmove(self.addr, code, size)
      else:
          import mmap  # Only import if necessary.
  
          self.mmap = mmap.mmap(
              -1,
              size,
              mmap.MAP_PRIVATE | mmap.MAP_ANONYMOUS,
              mmap.PROT_READ | mmap.PROT_WRITE | mmap.PROT_EXEC,
          )
          self.addr = ctypes.addressof(
              ctypes.c_void_p.from_buffer(self.mmap)
          )
          self.mmap.write(code)
  
      func_type = CFUNCTYPE(
          None, POINTER(CPUID_struct), c_uint32, c_uint32
      )
      self.func_ptr = func_type(self.addr)
  
file_path: polars/py-polars/polars/_cpu_check.py
imports: from __future__ import annotations
  import ctypes
  import os
  from ctypes import CFUNCTYPE, POINTER, c_long, c_size_t, c_uint32, c_ulong, c_void_p
  from typing import ClassVar
label_desc: Use image node_id 1 to create a new CPUID object  with example: obj = CPUID()