Segfault when going back to Object Mode, on unrelated data
Use a copy

centers = [p.center.copy() for p in obj.data.polygons]


Similarly for obj.location 

&gt;&gt;&gt; C.object.location
Vector((3.3187315464019775, 1.0073195695877075, 7.229274749755859))

&gt;&gt;&gt; v = C.object.location
&gt;&gt;&gt; vc = C.object.location.copy()
&gt;&gt;&gt; C.object.location = (0, 0, 0)
&gt;&gt;&gt; v
Vector((0.0, 0.0, 0.0))

&gt;&gt;&gt; vc
Vector((3.3187315464019775, 1.0073195695877075, 7.229274749755859))


v is a reference to the object location. It is bound to the object. Removing the object and trying to reference v again will lead to a seg fault.

Use v = C.object.location.copy() for an unbound "snapshot" copy.  (casting to list and back was doing this too)

Note centers.copy() was still a copy of a list whose items were references to a polygon and hence the mesh.

As pointed out by @MartinZ you can also set the select values in object mode. The foreach_set(prop, values) method is faster than iterating and setting, eg for polygons

&gt;&gt;&gt; me = C.object.data
&gt;&gt;&gt; me.polygons.foreach_set("select", [False] * len(me.polygons))
&gt;&gt;&gt;