From 4ab5d44eb1cbba65974bf706dbcc09d6b8f1bc31 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Fri, 14 Aug 2015 22:02:29 -0500
Subject: [PATCH] Keep Array.context around no matter what, rather than
 repeatedly getting it through get_info

---
 pyopencl/array.py | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/pyopencl/array.py b/pyopencl/array.py
index 713771f6..a9259fc5 100644
--- a/pyopencl/array.py
+++ b/pyopencl/array.py
@@ -550,7 +550,7 @@ class Array(object):
                 alloc_nbytes = 1
 
             if allocator is None:
-                if queue is not None:
+                if context is None and queue is not None:
                     context = queue.context
 
                 self.base_data = cl.Buffer(
@@ -561,15 +561,12 @@ class Array(object):
             self.base_data = data
 
         self.offset = offset
+        self.context = context
 
     @property
     def ndim(self):
         return len(self.shape)
 
-    @property
-    def context(self):
-        return self.base_data.context
-
     @property
     def data(self):
         if self.offset:
-- 
GitLab