Increase performances of the following code:
import numpy as np
import pinocchio
from scipy.spatial.transform import Rotation, Slerp

class myCartesianPlannerOptions:
    """Options for Cartesian planning."""

    def __init__(
        self,
        step_size=0.01,  # Distance step in meters
    ):
        """
        Initializes a set of Cartesian planning options.

        Parameters
        ----------
            step_size : float
                The distance between consecutive interpolated points, in meters.
        """
        if step_size <= 0:
            raise ValueError("Step size must be positive.")
        self.step_size = step_size

class myCartesianPlanner:
    """
    Simplified Cartesian (task space) motion planner that interpolates
    points based on a fixed step distance and solves inverse kinematics for each point.
    """

    def __init__(
        self, model, target_frame, tforms, ik_solver, options=myCartesianPlannerOptions()
    ):
        """
        Initializes a simplified Cartesian motion planner instance.

        Parameters
        ----------
            model : `pinocchio.Model`
                The model to use for motion planning.
            target_frame : str
                The name of the target frame in the model defining the Cartesian motion.
            tforms : list[`pinocchio.SE3`]
                A list of pose waypoints, in SE3, for the target frame to move through.
            ik_solver : any
                Any valid inverse kinematics solver from this library.
            options : `CartesianPlannerOptions`, optional
                A set of Cartesian planning options.
                If not set, a default set of options will be used.
        """
        self.model = model
        self.target_frame = target_frame
        self.tforms = tforms
        self.ik_solver = ik_solver
        self.options = options

    def interpolate_segment(self, start_tform, end_tform):
        """
        Interpolates a segment between two SE3 poses with step size `ds`.

        Parameters
        ----------
            start_tform : `pinocchio.SE3`
                The starting pose.
            end_tform : `pinocchio.SE3`
                The ending pose.

        Returns
        -------
            list[`pinocchio.SE3`]
                A list of interpolated poses between start and end.
        """
        # Calculate the difference in translation
        translation_start = start_tform.translation
        translation_end = end_tform.translation
        delta_translation = translation_end - translation_start
        linear_distance = np.linalg.norm(delta_translation)

        if linear_distance == 0:
            num_steps = 1
        else:
            num_steps = max(int(np.ceil(linear_distance / self.options.step_size)), 1)

        # Calculate the rotation difference using SLERP
        rotation_start = Rotation.from_matrix(start_tform.rotation)
        rotation_end = Rotation.from_matrix(end_tform.rotation)
        slerp = Slerp([0, 1], Rotation.concatenate([rotation_start, rotation_end]))

        self.generated_tforms = []
        for step in range(1, num_steps + 1):
            alpha = step / num_steps
            # Interpolate translation
            p = translation_start + alpha * delta_translation
            # Interpolate rotation
            R = slerp(alpha).as_matrix()
            self.generated_tforms.append(pinocchio.SE3(R, p))

        return self.generated_tforms

    def generate(self, q_init):
        """
        Generates a set of joint trajectories from the Cartesian plan by
        interpolating points with a fixed step distance and solving IK.

        Parameters
        ----------
            q_init : array-like
                The starting joint configuration for the robot.
                This is used as the initial condition for solving inverse kinematics.

        Returns
        -------
            tuple(bool, list[`pinocchio.SE3`], list[array-like])
                The tuple of (success, list of poses, list of joint configurations).
        """
        self.generated_tforms = []
        self.joint_trajectory = []

        q_current = q_init.copy()
        self.joint_trajectory.append(q_current)

        for idx in range(1, len(self.tforms)):
            start_tform = self.tforms[idx - 1]
            end_tform = self.tforms[idx]
            segment_tforms = self.interpolate_segment(start_tform, end_tform)

            for t_idx, tform in enumerate(segment_tforms):
                self.generated_tforms.append(tform)

                # Solve IK with the current pose and current joint configuration as the initial guess
                q_sol = self.ik_solver.solve(
                    self.target_frame, tform, init_state=q_current
                )

                if q_sol is not None:
                    self.joint_trajectory.append(q_sol)
                    q_current = q_sol
                else:
                    print(f"Failed to solve IK for interpolated point {len(self.joint_trajectory)}")
                    return False, self.generated_tforms, self.joint_trajectory

        return True, self.generated_tforms, self.joint_trajectory