Scaling objects with data modification I am fairly new to blender and am wondering how does one scale the objects in blender via python script.

Currently I am simply changing the scale of the object via bpy.data.objects[NAME].scale
however, this is not what I want to do as it only visually shrink the object.

I also tried to change the length of each bone individually, however, even though the length of the bone changed, the head and tail of the bone did not change. Also something worth mentioning, I am working with a hand. This ended up giving me a hand with tiny bones but not connected due to the bone's head remaining the same.

I would like the bones in the armature object to actually shrink/grow as well, since I am exporting this object later as BVH and would like to preserve the scaling.

Thanks
this is simple script for scaling all bones in the active armature :

import bpy
ob = bpy.context.object
bpy.ops.object.mode_set(mode='POSE')

for bone in ob.pose.bones:    
     if not bone.parent : # since children inherit scale no need to scale them 
        bone.scale *=0.5

bpy.ops.object.mode_set(mode='OBJECT')


to remove scale inheritence  :

for bone in ob.data.bones:
        if bone.parent :
            bone.use_inherit_scale = False

#scale all bones
bpy.ops.object.mode_set(mode='POSE')
for bone in ob.pose.bones:    
        bone.scale *=0.5
bpy.ops.object.mode_set(mode='OBJECT')


scaling in edit mode :

import mathutils
bpy.ops.object.mode_set(mode='EDIT')

mat = mathutils.Matrix.Scale(0.5, 3)

for bone in ob.data.edit_bones:
        bone.transform(mat,  scale = True, roll = False)

bpy.ops.object.mode_set(mode='OBJECT')