Check out the following Github repository for example code:
You can use a particle system to render the vertices.
I found that this is less memory/computational expensive than using DupliVerts. (A single material can be used to colorize all particles/vertices)
You need two different blender objects for this method (One object with vertices you want to render, one object used for representing the vertices (in this example a cube))
See the settings of the particle system as shown in the image below. (Adjust the emission number as well as the hair length according to your needs.)
To colorize the different vertices set the material of the cube as follows:
The image texture node points to a texture which has a dimension of (number_vertices, 1). Each pixel defines the color for a specific vertex.
Here is an excerpt of the code I used to generate the corresponding texture image.
num_points = len(points)
image = bpy.data.images.new('ParticleColor', num_points, 1)
# working on a copy of the pixels results in a MASSIVE gain of performance speed
local_pixels = list(image.pixels[:])
for point_index, point in enumerate(points):
column_offset = point_index * 4 # (R,G,B,A)
color = point.color
# Order is R,G,B, opacity
local_pixels[column_offset] = color / 255.0
local_pixels[column_offset + 1] = color / 255.0
local_pixels[column_offset + 2] = color / 255.0
# opacity (0 = transparent, 1 = opaque)
#local_pixels[column_offset + 3] = 1.0 # already set by default
image.pixels = local_pixels[:]
image_texture_node.image = image