Animated text body drops Playback FPS by half I'm developing my first Add-On, its main purpose is to visualize Scientific Data (BlenderNC), I'm using Blender v2.83 (Mac OS 10.15.5, 16GB RAM, Radeon Pro 555 2 GB). As a feature, I want to animate text in the Camera view to display the daytime or step of the data on each frame. If the update text function is unregistered the Playback FPS is ~60 fps (Fig.1), however, once I register the function the Playback FPS drops to half (~27 FPS; Fig.2). I'm using the attached script to reproduce this issue. This drop by half significantly affects the display in Real-Time of scientific data.
Is there anything I could do to improve the Playback FPS?
import bpy
from bpy.app.handlers import persistent
import time

@persistent
def update_frame(scene,context):
    tic = time.time()
    time_t = bpy.context.scene.frame_current
    print(time.time()-tic)
    if 'Camera' in bpy.data.objects.keys() and time:
        tic = time.time()
        Camera = bpy.data.objects.get('Camera')
        size = 0.03
        coords = (-0.35,0.17,-1)
        children_name  = [children.name for children in  Camera.children]
        print(time.time()-tic)
        if &quot;BlenderNC_time&quot; not in children_name:
            tic = time.time()
            bpy.ops.object.text_add(radius=size)
            text=bpy.context.object
            text.name=&quot;BlenderNC_time&quot;
            text.parent = Camera
            text.location = coords  
            print(time.time()-tic)
        else:
            tic = time.time()
            childrens = Camera.children
            text = [child for child in childrens if child.name==&quot;BlenderNC_time&quot;][-1]
            print(time.time()-tic)
        tic = time.time()
        text.data.body = str(time_t)
        text.select_set(False) 
        print(time.time()-tic )

        
handlers = bpy.app.handlers
        
def registerBlenderNC():
    bpy.types.Scene.update_frame = update_frame
    handlers.frame_change_pre.append(bpy.types.Scene.update_frame)
    
    
def unregisterBlenderNC():
    del bpy.types.Scene.update_frame
    handlers.frame_change_pre.remove(update_frame) 
    
registerBlenderNC()

Example in Blender default scene, unregistered text update:

Example in Blender default scene, registered text update:
The issue was with unselecting the text object:
text.select_set(False) 

testing if the text object is selected, to then unset it solved the issue.
if text.select_get():
    text.select_set(False) 

Full fixed code:
import bpy
from bpy.app.handlers import persistent
import time

@persistent
def update_frame(scene,context):
    tic = time.time()
    time_t = bpy.context.scene.frame_current
    print(time.time()-tic)
    if 'Camera' in bpy.data.objects.keys() and time:
        tic = time.time()
        Camera = bpy.data.objects.get('Camera')
        size = 0.03
        coords = (-0.35,0.17,-1)
        children_name  = [children.name for children in  Camera.children]
        print(time.time()-tic)
        if &quot;BlenderNC_time&quot; not in children_name:
            tic = time.time()
            bpy.ops.object.text_add(radius=size)
            text=bpy.context.object
            text.name=&quot;BlenderNC_time&quot;
            text.parent = Camera
            text.location = coords  
            print(time.time()-tic)
        else:
            tic = time.time()
            childrens = Camera.children
            text = [child for child in childrens if child.name==&quot;BlenderNC_time&quot;][-1]
            print(time.time()-tic)
        tic = time.time()
        text.data.body = str(time_t)
        if text.select_get():
            text.select_set(False) 
        print(time.time()-tic )

        
handlers = bpy.app.handlers
        
def registerBlenderNC():
    bpy.types.Scene.update_frame = update_frame
    handlers.frame_change_pre.append(bpy.types.Scene.update_frame)
    
    
def unregisterBlenderNC():
    del bpy.types.Scene.update_frame
    handlers.frame_change_pre.remove(update_frame) 
    
registerBlenderNC()