# Editing fcurve.keyframe points in FAST mode?

I can add and remove keyframes like this via python, no issues arise.

#remove all existing keys
for i in reversed(range(0, len(fcu.keyframe_points))):
fcu.keyframe_points.remove(fcu.keyframe_points[i])
#insert the corrected keys
for frame, sample in zip(new_frames, new_samples):
fcu.keyframe_points.insert(frame, sample)


But I want to use the fast option to avoid updating the fcurve after each modification and only update after the loop:

#remove all existing keys
for i in reversed(range(0, len(fcu.keyframe_points))):
fcu.keyframe_points.remove(fcu.keyframe_points[i], fast=True)
fcu.update()
#insert the corrected keys
for frame, sample in zip(new_frames, new_samples):
fcu.keyframe_points.insert(frame, sample, set(("FAST", )))
fcu.update()


Now that code is also functional, but in the dope sheet, the resulting keyframes are dark grey instead of the usual white. Anything I'm missing or is this intended behavior? Does the color have any significance?

This answer doesn't address the FAST mode issue, it is another method to clear an fcurve and set new points that avoids looping, reversing or using either the insert or remove methods of FCurve.keyframe_points entirely.

import bpy
frames = [1, 9, 20]
samples = [0, 8, 0]
# some action
a = bpy.data.actions["SomeAction"]
fc = a.fcurves[0] # some fcurve
dp, i = fc.data_path, fc.array_index
# clear the fcurve by removing it
a.fcurves.remove(fc)
# new one
fc = a.fcurves.new(dp, index=i)
# new points