Blender becomes very slow with large amount of objects sharing mesh data
You're sharing one object data (Primary) among +2500 objects, but with this line:

bpy.data.meshes.new('Sphere')


... you're also creating +2500 orphan mesh data. It's easy to add several MBs to Blender's memory usage (verifiable through System Monitor), just running that bit of code:

import bpy

for i in range(1, 2500):
    bpy.data.meshes.new('Sphere')


The orphaned obdatas won't be reclaimed until loading new scene or quitting (to see them, select a mesh object, click the dropdown button to the left of the obdata's name in Properties area's Object Data tab). For scenes large enough, in systems with low RAM, this could slow down the whole system.