diff --git a/examples/from-wiki/gpu_scalar_mult.py b/examples/from-wiki/gpu_scalar_mult.py index 159986e2..fa11f815 100644 --- a/examples/from-wiki/gpu_scalar_mult.py +++ b/examples/from-wiki/gpu_scalar_mult.py @@ -55,18 +55,15 @@ def get_lin_comb_kernel_no_tex(summand_descriptors, for i, (is_gpu_scalar, scalar_dtype, vector_dtype) in \ enumerate(summand_descriptors): if is_gpu_scalar: - args.append(VectorArg(vector_dtype, "global_a%d" % i)) - args.append(VectorArg(vector_dtype, "x%d" % i)) + args.extend((VectorArg(vector_dtype, "global_a%d" % i), VectorArg(vector_dtype, "x%d" % i))) loop_prep.append("%s a%d = *global_a%d" % (dtype_to_ctype(scalar_dtype), i, i)) else: - args.append(ScalarArg(scalar_dtype, "a%d" % i)) - args.append(VectorArg(vector_dtype, "x%d" % i)) + args.extend((ScalarArg(scalar_dtype, "a%d" % i), VectorArg(vector_dtype, "x%d" % i))) summands.append("a%d*x%d[i]" % (i, i)) - args.append(VectorArg(dtype_z, "z")) - args.append(ScalarArg(numpy.uintp, "n")) + args.extend((VectorArg(dtype_z, "z"), ScalarArg(numpy.uintp, "n"))) mod = get_elwise_module(args, "z[i] = " + " + ".join(summands), diff --git a/pycuda/debug.py b/pycuda/debug.py index a8c0b095..f2973b08 100644 --- a/pycuda/debug.py +++ b/pycuda/debug.py @@ -27,4 +27,4 @@ sys.argv = args with open(mainpyfile) as mainpy: - exec(compile(mainpy.read(), mainpyfile, "exec")) # ruff:ignore[exec-builtin] + exec(compile(mainpy.read(), mainpyfile, "exec")) diff --git a/pycuda/driver.py b/pycuda/driver.py index 45822b64..e326cbbe 100644 --- a/pycuda/driver.py +++ b/pycuda/driver.py @@ -340,7 +340,7 @@ def function_prepare_pre_v4(func, arg_types, block=None, shared=None, texrefs=No func.arg_format = "" - for _i, arg_type in enumerate(arg_types): + for arg_type in arg_types: if ( isinstance(arg_type, type) and np is not None @@ -541,7 +541,7 @@ def function_prepare(func, arg_types, texrefs=None): func.arg_format = "" - for _i, arg_type in enumerate(arg_types): + for arg_type in arg_types: if isinstance(arg_type, type) and np.number in arg_type.__mro__: func.arg_format += np.dtype(arg_type).char elif isinstance(arg_type, np.dtype): diff --git a/pycuda/elementwise.py b/pycuda/elementwise.py index a2bee436..02e169da 100644 --- a/pycuda/elementwise.py +++ b/pycuda/elementwise.py @@ -269,8 +269,7 @@ def __call__(self, *args, **kwargs): range_ = slice(*slice_.indices(repr_vec.size)) if range_ is not None: - invocation_args.append(range_.start) - invocation_args.append(range_.stop) + invocation_args.extend((range_.start, range_.stop)) if range_.step is None: invocation_args.append(1) else: @@ -439,13 +438,11 @@ def get_linear_combination_kernel(summand_descriptors, dtype_z): % (dtype_to_ctype(scalar_dtype), i, i) ) else: - args.append(ScalarArg(scalar_dtype, "a%d" % i)) - args.append(VectorArg(vector_dtype, "x%d" % i)) + args.extend((ScalarArg(scalar_dtype, "a%d" % i), VectorArg(vector_dtype, "x%d" % i))) summands.append("a%d*x%d[i]" % (i, i)) - args.append(VectorArg(dtype_z, "z")) - args.append(ScalarArg(np.uintp, "n")) + args.extend((VectorArg(dtype_z, "z"), ScalarArg(np.uintp, "n"))) mod = get_elwise_module( args, diff --git a/pycuda/gl/autoinit.py b/pycuda/gl/autoinit.py index e4104774..169333f2 100644 --- a/pycuda/gl/autoinit.py +++ b/pycuda/gl/autoinit.py @@ -12,7 +12,7 @@ from pycuda.tools import make_default_context -context = make_default_context(lambda dev: cudagl.make_context(dev)) +context = make_default_context(cudagl.make_context) device = context.get_device() atexit.register(context.pop) diff --git a/pycuda/gpuarray.py b/pycuda/gpuarray.py index fedd4bf0..1a7e57c5 100644 --- a/pycuda/gpuarray.py +++ b/pycuda/gpuarray.py @@ -419,7 +419,7 @@ def __bool__(self): @property def ptr(self): - return self.gpudata.__int__() + return int(self.gpudata) # kernel invocation wrappers ---------------------------------------------- def _axpbyz(self, selffac, other, otherfac, out, add_timer=None, stream=None): diff --git a/pycuda/sparse/cg.py b/pycuda/sparse/cg.py index fbf341a6..cd745c96 100644 --- a/pycuda/sparse/cg.py +++ b/pycuda/sparse/cg.py @@ -62,9 +62,7 @@ def lc2(self, a, x, b, y, out=None): b.bind_to_texref_ext(texrefs.pop(0), allow_double_hack=True) else: args.append(b) - args.append(y.gpudata) - args.append(out.gpudata) - args.append(x.mem_size) + args.extend((y.gpudata, out.gpudata, x.mem_size)) kernel.prepared_call(x._grid, x._block, *args) diff --git a/test/test_gpuarray.py b/test/test_gpuarray.py index 3e9d0091..95c457e0 100644 --- a/test/test_gpuarray.py +++ b/test/test_gpuarray.py @@ -26,7 +26,7 @@ def get_random_array(rng, shape, dtype): return rng.random(shape, dtype) elif dtype.kind in "il": return rng.integers(-42, 42, shape, dtype) - elif dtype.kind in "u": + elif dtype.kind == "u": return rng.integers(0, 42, shape, dtype) elif dtype.kind == "c": real_dtype = np.empty(0, dtype).real.dtype