How to mathematically round positions of all vertices to nearest integer? I have a mesh with 1.5M vertices, and I'm trying to round off vertex positions to reduce the filesize of my exported .obj file. Each vertex has a very high level of precision, which I don't really need for this project. For example, I have a vertex at [492.98198, 382.19873, 274.98789], and would like to run a Python script to round it to [493, 382, 275], effectively reducing my output by over 50%!

Is there a python script that I could run to round off all 1.5M of my vertices in one go? This is as far as I've gone:

for vertex in bpy.data.meshes['meshname'].vertices:
    vertex.co[0] = round(vertex.co[0], 0)
    vertex.co[1] = round(vertex.co[1], 0)
    vertex.co[2] = round(vertex.co[2], 0)


But it seems like I can't really change the vertex values this way because mesh.vertices is a readonly attribute. 

Anybody know how to modify the script so my vertices all snap to the nearest integer?
Use the following script:

import bpy

obj = bpy.context.scene.objects.active

for vert in obj.data.vertices:
    vert.co.x = round(vert.co.x)
    vert.co.y = round(vert.co.y)
    vert.co.z = round(vert.co.z)


Let me know if you run into any problems :-)