pickle a kdtree and indexed list ? (a grid of kdtree)

What format could I write, and recall picked kdtree?

I was thinking of a large dynamic open world, where objects whos kdtree is outside a range, get collapsed to a file and delete all the game objects,

next time you near the area, the kdtree is opened and the objects are added to the scene over time,

terrain = all the same instance of planes using vertex splat mapling and being deformed by a height map table.

The important part here, how do I save a kdtree ?

…what is a kdtree… sorry for the noob question…

mathutils.kdTree is a method for detecting all objects/points in a radius, or the closest x objects/points, at a low cost compared to itterating a list in python,

you can use it for manipulating points in a mesh without a high cost, or manipulating loading objects in and out that are static,
or for getting the closest x lamp hooks to populate with lamps
(static light sources)

only typically useful for static data sets, as you need to rebalance the tree if you move an object in the tree.

basically by using a kdtree and a indexed list,
you can select sets of data to operate on.

edit: here is an example of a kdtree, this is physics and dynamic lighting lod.
http://www.pasteall.org/blend/42172

If you want to save something you might find JSON easier since it’s more readable in text form.

If you want to try and save python objects like classes pickle is the way to go, but it doesn’t always work. It won’t save game objects since they are not pure python objects. I’m not sure about kd tree if it’s picklable or not. You should try it and see.

Pickle
Pickle means your convert the python object to a storable format, while unpickle creates a new python object (of the same class) from that read data.

Why not simply try it, rather than asking. It is really not hard to write a little test code.