prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Use CPython allocator in NRT
  NRT should optionally use the CPython memory allocation functions (when imported from CPython). This would allow Numba-allocated memory to be seen by other utilities such as `sys.getallocatedblocks()`, `sys.debugmallocstats()`, and `tracemalloc`.
  
  
  </issue>
  <code>
  [start of numba/runtime/nrt.py]
  1 from __future__ import print_function, absolute_import, division
  2 
  3 from collections import namedtuple
  4 
  5 from . import atomicops
  6 from llvmlite import binding as ll
  7 
  8 from numba.utils import finalize as _finalize
  9 from . import _nrt_python as _nrt
  10 
  11 _nrt_mstats = namedtuple("nrt_mstats", ["alloc", "free", "mi_alloc", "mi_free"])
  12 
  13 
  14 class _Runtime(object):
  15     def __init__(self):
  16         self._init = False
  17 
  18     def initialize(self, ctx):
  19         """Initializes the NRT
  20 
  21         Must be called before any actual call to the NRT API.
  22         Safe to be called multiple times.
  23         """
  24         if self._init:
  25             # Already initialized
  26             return
  27 
  28         # Register globals into the system
  29         for py_name in _nrt.c_helpers:
  30             c_name = "NRT_" + py_name
  31             c_address = _nrt.c_helpers[py_name]
  32             ll.add_symbol(c_name, c_address)
  33 
  34         # Compile atomic operations
  35         self._library = atomicops.compile_nrt_functions(ctx)
  36 
  37         self._ptr_inc = self._library.get_pointer_to_function("nrt_atomic_add")
  38         self._ptr_dec = self._library.get_pointer_to_function("nrt_atomic_sub")
  39         self._ptr_cas = self._library.get_pointer_to_function("nrt_atomic_cas")
  40 
  41         # Install atomic ops to NRT
  42         _nrt.memsys_set_atomic_inc_dec(self._ptr_inc, self._ptr_dec)
  43         _nrt.memsys_set_atomic_cas(self._ptr_cas)
  44 
  45         self._init = True
  46 
  47     @staticmethod
  48     def shutdown():
  49         """
  50         Shutdown the NRT
  51         Safe to be called without calling Runtime.initialize first
  52         """
  53         _nrt.memsys_shutdown()
  54 
  55     @property
  56     def library(self):
  57         """
  58         Return the Library object containing the various NRT functions.
  59         """
  60         return self._library
  61 
  62     def meminfo_new(self, data, pyobj):
  63         """
  64         Returns a MemInfo object that tracks memory at `data` owned by `pyobj`.
  65         MemInfo will acquire a reference on `pyobj`.
  66         The release of MemInfo will release a reference on `pyobj`.
  67         """
  68         mi = _nrt.meminfo_new(data, pyobj)
  69         return MemInfo(mi)
  70 
  71     def meminfo_alloc(self, size, safe=False):
  72         """
  73         Allocate a new memory of `size` bytes and returns a MemInfo object
  74         that tracks the allocation.  When there is no more reference to the
  75         MemInfo object, the underlying memory will be deallocated.
  76 
  77         If `safe` flag is True, the memory is allocated using the `safe` scheme.
  78         This is used for debugging and testing purposes.
  79         See `NRT_MemInfo_alloc_safe()` in "nrt.h" for details.
  80         """
  81         if safe:
  82             mi = _nrt.meminfo_alloc_safe(size)
  83         else:
  84             mi = _nrt.meminfo_alloc(size)
  85         return MemInfo(mi)
  86 
  87     def get_allocation_stats(self):
  88         """
  89         Returns a namedtuple of (alloc, free, mi_alloc, mi_free) for count of
  90         each memory operations.
  91         """
  92         return _nrt_mstats(alloc=_nrt.memsys_get_stats_alloc(),
  93                            free=_nrt.memsys_get_stats_free(),
  94                            mi_alloc=_nrt.memsys_get_stats_mi_alloc(),
  95                            mi_free=_nrt.memsys_get_stats_mi_free())
  96 
  97 
  98 # Alias to _nrt_python._MemInfo
  99 MemInfo = _nrt._MemInfo
  100 
  101 # Create uninitialized runtime
  102 rtsys = _Runtime()
  103 
  104 # Install finalizer
  105 _finalize(rtsys, _Runtime.shutdown)
  106 
  107 # Avoid future use of the class
  108 del _Runtime
  109
  [end of numba/runtime/nrt.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/numba/runtime/nrt.py b/numba/runtime/nrt.py
  --- a/numba/runtime/nrt.py
  +++ b/numba/runtime/nrt.py
  @@ -98,7 +98,8 @@
   # Alias to _nrt_python._MemInfo
   MemInfo = _nrt._MemInfo
   
  -# Create uninitialized runtime
  +# Create runtime
  +_nrt.memsys_use_cpython_allocator()
   rtsys = _Runtime()
   
   # Install finalizer
  
verification_info: {"golden_diff": "diff --git a/numba/runtime/nrt.py b/numba/runtime/nrt.py\n--- a/numba/runtime/nrt.py\n+++ b/numba/runtime/nrt.py\n@@ -98,7 +98,8 @@\n # Alias to _nrt_python._MemInfo\n MemInfo = _nrt._MemInfo\n \n-# Create uninitialized runtime\n+# Create runtime\n+_nrt.memsys_use_cpython_allocator()\n rtsys = _Runtime()\n \n # Install finalizer\n", "issue": "Use CPython allocator in NRT\nNRT should optionally use the CPython memory allocation functions (when imported from CPython). This would allow Numba-allocated memory to be seen by other utilities such as `sys.getallocatedblocks()`, `sys.debugmallocstats()`, and `tracemalloc`.\n\n", "before_files": [{"content": "from __future__ import print_function, absolute_import, division\n\nfrom collections import namedtuple\n\nfrom . import atomicops\nfrom llvmlite import binding as ll\n\nfrom numba.utils import finalize as _finalize\nfrom . import _nrt_python as _nrt\n\n_nrt_mstats = namedtuple(\"nrt_mstats\", [\"alloc\", \"free\", \"mi_alloc\", \"mi_free\"])\n\n\nclass _Runtime(object):\n    def __init__(self):\n        self._init = False\n\n    def initialize(self, ctx):\n        \"\"\"Initializes the NRT\n\n        Must be called before any actual call to the NRT API.\n        Safe to be called multiple times.\n        \"\"\"\n        if self._init:\n            # Already initialized\n            return\n\n        # Register globals into the system\n        for py_name in _nrt.c_helpers:\n            c_name = \"NRT_\" + py_name\n            c_address = _nrt.c_helpers[py_name]\n            ll.add_symbol(c_name, c_address)\n\n        # Compile atomic operations\n        self._library = atomicops.compile_nrt_functions(ctx)\n\n        self._ptr_inc = self._library.get_pointer_to_function(\"nrt_atomic_add\")\n        self._ptr_dec = self._library.get_pointer_to_function(\"nrt_atomic_sub\")\n        self._ptr_cas = self._library.get_pointer_to_function(\"nrt_atomic_cas\")\n\n        # Install atomic ops to NRT\n        _nrt.memsys_set_atomic_inc_dec(self._ptr_inc, self._ptr_dec)\n        _nrt.memsys_set_atomic_cas(self._ptr_cas)\n\n        self._init = True\n\n    @staticmethod\n    def shutdown():\n        \"\"\"\n        Shutdown the NRT\n        Safe to be called without calling Runtime.initialize first\n        \"\"\"\n        _nrt.memsys_shutdown()\n\n    @property\n    def library(self):\n        \"\"\"\n        Return the Library object containing the various NRT functions.\n        \"\"\"\n        return self._library\n\n    def meminfo_new(self, data, pyobj):\n        \"\"\"\n        Returns a MemInfo object that tracks memory at `data` owned by `pyobj`.\n        MemInfo will acquire a reference on `pyobj`.\n        The release of MemInfo will release a reference on `pyobj`.\n        \"\"\"\n        mi = _nrt.meminfo_new(data, pyobj)\n        return MemInfo(mi)\n\n    def meminfo_alloc(self, size, safe=False):\n        \"\"\"\n        Allocate a new memory of `size` bytes and returns a MemInfo object\n        that tracks the allocation.  When there is no more reference to the\n        MemInfo object, the underlying memory will be deallocated.\n\n        If `safe` flag is True, the memory is allocated using the `safe` scheme.\n        This is used for debugging and testing purposes.\n        See `NRT_MemInfo_alloc_safe()` in \"nrt.h\" for details.\n        \"\"\"\n        if safe:\n            mi = _nrt.meminfo_alloc_safe(size)\n        else:\n            mi = _nrt.meminfo_alloc(size)\n        return MemInfo(mi)\n\n    def get_allocation_stats(self):\n        \"\"\"\n        Returns a namedtuple of (alloc, free, mi_alloc, mi_free) for count of\n        each memory operations.\n        \"\"\"\n        return _nrt_mstats(alloc=_nrt.memsys_get_stats_alloc(),\n                           free=_nrt.memsys_get_stats_free(),\n                           mi_alloc=_nrt.memsys_get_stats_mi_alloc(),\n                           mi_free=_nrt.memsys_get_stats_mi_free())\n\n\n# Alias to _nrt_python._MemInfo\nMemInfo = _nrt._MemInfo\n\n# Create uninitialized runtime\nrtsys = _Runtime()\n\n# Install finalizer\n_finalize(rtsys, _Runtime.shutdown)\n\n# Avoid future use of the class\ndel _Runtime\n", "path": "numba/runtime/nrt.py"}]}