Repository: matplotlib/matplotlib
File: lib/matplotlib/widgets.py (Python)

Code before:
            Dictionary of `.Text` properties to be used for the labels. Each
            dictionary value should be a list of at least a single element. If
            the list is of length M, its values are cycled such that the Nth
            label gets the (N mod M) property.

            .. versionadded:: 3.7
        radio_props : dict, optional
            Dictionary of scatter `.Collection` properties to be used for the
            radio buttons. Defaults to (label font size / 2)**2 size, black
            edgecolor, and *activecolor* facecolor (when active).

            .. note::
                If a facecolor is supplied in *radio_props*, it will override
                *activecolor*. This may be used to provide an active color per
                button.

            .. versionadded:: 3.7
        """
        super().__init__(ax)

        _api.check_isinstance((dict, None), label_props=label_props,
                              radio_props=radio_props)

        labels = list(labels)
        n_labels = len(labels)

        radio_props = cbook.normalize_kwargs(radio_props,
                                             collections.PathCollection)
        if activecolor is not None:
            if 'facecolor' in radio_props:
                _api.warn_external(
                    'Both the *activecolor* parameter and the *facecolor* '
                    'key in the *radio_props* parameter has been specified. '
                    '*activecolor* will be ignored.')
        else:
            activecolor = 'blue'  # Default.

        self._activecolor = activecolor
        self._initial_active = active
        self.value_selected = labels[active]
        self.index_selected = active

        ax.set_xticks([])
        ax.set_yticks([])
        ax.set_navigate(False)

        self._useblit = useblit and self.canvas.supports_blit
        self._background = None

        label_props = _expand_text_props(label_props)


Review comment (suggestion):
```suggestion
```
Conversion to list is not necessary. Also before, we required that `labels` is iterable and has a `__len__`.
`n_labels` is only used once in the function -> no benefit in declaring a separate variable; keep inline

Code after:

    Attributes
    ----------
    ax : `~matplotlib.axes.Axes`
        The parent Axes for the widget.
    activecolor : :mpltype:`color`
        The color of the selected button.
    labels : list of `.Text`
        The button labels.
    value_selected : str
        The label text of the currently selected button.
    index_selected : int
        The index of the selected button.
    """

    def __init__(self, ax, labels, active=0, activecolor=None, *, layout=None,
                 useblit=True, label_props=None, radio_props=None):
        """
        Add radio buttons to an `~.axes.Axes`.

        Parameters
        ----------
        ax : `~matplotlib.axes.Axes`
            The Axes to add the buttons to.
        labels : list of str
            The button labels.
        active : int
            The index of the initially selected button.
        activecolor : :mpltype:`color`
            The color of the selected button. The default is ``'blue'`` if not
            specified here or in *radio_props*.
        layout : None or "vertical" or "horizontal" or (int, int), default: None
            The layout of the radio buttons. Options are:

            - ``None``: Use legacy vertical layout (default).
            - ``"vertical"``: Arrange buttons in a single column with
              dynamic positioning based on text widths.
            - ``"horizontal"``: Arrange buttons in a single row with
              dynamic positioning based on text widths.
            - ``(rows, cols)`` tuple: Arrange buttons in a grid with the
              specified number of rows and columns. Buttons are placed
              left-to-right, top-to-bottom with dynamic positioning.

            The layout options "vertical", "horizontal" and ``(rows, cols)``
            create ``mtext.Text`` objects to determine exact text sizes, and
            then they are added to the Axes. This is usually okay, but may cause
            side-effects and has a slight performance impact. Therefore the
            default ``None`` value avoids this.

            .. admonition:: Provisional
                The new layout options are provisional. Their algorithmic