We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
PERF: `to_set` speeds up especial to large data
<!--
Thanks for contributing a pull request!

Please follow these standard acronyms to start the commit message:

- ENH: enhancement
- BUG: bug fix
- DOC: documentation
- TYP: type annotations
- TST: addition or modification of tests
- MAINT: maintenance commit (refactoring, typos, etc.)
- BLD: change related to building
- REL: related to releasing
- API: an (incompatible) API change
- DEP: deprecate something, or remove a deprecated object
- DEV: development tool or utility
- REV: revert an earlier commit
- PERF: performance improvement
- BOT: always commit via a bot
- CI: related to CI or CD
- CLN: Code cleanup
-->

- [x] closes #542
- [x] whatsnew entry

Apply to index accessor

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `dtoolkit/accessor/index/to_set.py`
Content:
```
1 import pandas as pd
2 
3 from dtoolkit.accessor.register import register_index_method
4 
5 
6 @register_index_method
7 def to_set(index: pd.Index) -> set:
8     """
9     Return a :keyword:`set` of the values.
10 
11     A sugary syntax wraps :keyword:`set`::
12 
13         set(index)
14 
15     Different to :meth:`~pandas.Index.unique`, it returns :class:`~pandas.Index`.
16 
17     Returns
18     -------
19     set
20 
21     See Also
22     --------
23     pandas.Index.unique
24 
25     Examples
26     --------
27     >>> import dtoolkit.accessor
28     >>> import pandas as pd
29     >>> i = pd.Index([1, 2, 2])
30     >>> i
31     Int64Index([1, 2, 2], dtype='int64')
32     >>> i.to_set()
33     {1, 2}
34     """
35 
36     return set(index.unique())
37
```

Path: `dtoolkit/accessor/series/to_set.py`
Content:
```
1 import pandas as pd
2 
3 from dtoolkit.accessor.register import register_series_method
4 
5 
6 @register_series_method
7 def to_set(s: pd.Series) -> set:
8     """
9     Return a :keyword:`set` of the values.
10 
11     A sugary syntax wraps :keyword:`set`::
12 
13         set(s)
14 
15     Different to :meth:`~pandas.Series.unique`, it returns :class:`~numpy.ndarray`.
16 
17     Returns
18     -------
19     set
20 
21     See Also
22     --------
23     pandas.Series.unique
24 
25     Examples
26     --------
27     >>> import dtoolkit.accessor
28     >>> import pandas as pd
29     >>> s = pd.Series([1, 2, 2])
30     >>> s
31     0    1
32     1    2
33     2    2
34     dtype: int64
35     >>> s.to_set()
36     {1, 2}
37     """
38 
39     return set(s.unique())
40
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dtoolkit/accessor/index/to_set.py b/dtoolkit/accessor/index/to_set.py
--- a/dtoolkit/accessor/index/to_set.py
+++ b/dtoolkit/accessor/index/to_set.py
@@ -21,6 +21,7 @@
     See Also
     --------
     pandas.Index.unique
+    dtoolkit.accessor.series.to_set
 
     Examples
     --------
diff --git a/dtoolkit/accessor/series/to_set.py b/dtoolkit/accessor/series/to_set.py
--- a/dtoolkit/accessor/series/to_set.py
+++ b/dtoolkit/accessor/series/to_set.py
@@ -21,6 +21,7 @@
     See Also
     --------
     pandas.Series.unique
+    dtoolkit.accessor.index.to_set
 
     Examples
     --------
@@ -36,4 +37,4 @@
     {1, 2}
     """
 
-    return set(s.unique())
+    return set(s.to_list())

{"golden_diff": "diff --git a/dtoolkit/accessor/index/to_set.py b/dtoolkit/accessor/index/to_set.py\n--- a/dtoolkit/accessor/index/to_set.py\n+++ b/dtoolkit/accessor/index/to_set.py\n@@ -21,6 +21,7 @@\n     See Also\n     --------\n     pandas.Index.unique\n+    dtoolkit.accessor.series.to_set\n \n     Examples\n     --------\ndiff --git a/dtoolkit/accessor/series/to_set.py b/dtoolkit/accessor/series/to_set.py\n--- a/dtoolkit/accessor/series/to_set.py\n+++ b/dtoolkit/accessor/series/to_set.py\n@@ -21,6 +21,7 @@\n     See Also\n     --------\n     pandas.Series.unique\n+    dtoolkit.accessor.index.to_set\n \n     Examples\n     --------\n@@ -36,4 +37,4 @@\n     {1, 2}\n     \"\"\"\n \n-    return set(s.unique())\n+    return set(s.to_list())\n", "issue": "PERF: `to_set` speeds up especial to large data\n<!--\r\nThanks for contributing a pull request!\r\n\r\nPlease follow these standard acronyms to start the commit message:\r\n\r\n- ENH: enhancement\r\n- BUG: bug fix\r\n- DOC: documentation\r\n- TYP: type annotations\r\n- TST: addition or modification of tests\r\n- MAINT: maintenance commit (refactoring, typos, etc.)\r\n- BLD: change related to building\r\n- REL: related to releasing\r\n- API: an (incompatible) API change\r\n- DEP: deprecate something, or remove a deprecated object\r\n- DEV: development tool or utility\r\n- REV: revert an earlier commit\r\n- PERF: performance improvement\r\n- BOT: always commit via a bot\r\n- CI: related to CI or CD\r\n- CLN: Code cleanup\r\n-->\r\n\r\n- [x] closes #542\r\n- [x] whatsnew entry\r\n\r\nApply to index accessor\n", "before_files": [{"content": "import pandas as pd\n\nfrom dtoolkit.accessor.register import register_index_method\n\n\n@register_index_method\ndef to_set(index: pd.Index) -> set:\n    \"\"\"\n    Return a :keyword:`set` of the values.\n\n    A sugary syntax wraps :keyword:`set`::\n\n        set(index)\n\n    Different to :meth:`~pandas.Index.unique`, it returns :class:`~pandas.Index`.\n\n    Returns\n    -------\n    set\n\n    See Also\n    --------\n    pandas.Index.unique\n\n    Examples\n    --------\n    >>> import dtoolkit.accessor\n    >>> import pandas as pd\n    >>> i = pd.Index([1, 2, 2])\n    >>> i\n    Int64Index([1, 2, 2], dtype='int64')\n    >>> i.to_set()\n    {1, 2}\n    \"\"\"\n\n    return set(index.unique())\n", "path": "dtoolkit/accessor/index/to_set.py"}, {"content": "import pandas as pd\n\nfrom dtoolkit.accessor.register import register_series_method\n\n\n@register_series_method\ndef to_set(s: pd.Series) -> set:\n    \"\"\"\n    Return a :keyword:`set` of the values.\n\n    A sugary syntax wraps :keyword:`set`::\n\n        set(s)\n\n    Different to :meth:`~pandas.Series.unique`, it returns :class:`~numpy.ndarray`.\n\n    Returns\n    -------\n    set\n\n    See Also\n    --------\n    pandas.Series.unique\n\n    Examples\n    --------\n    >>> import dtoolkit.accessor\n    >>> import pandas as pd\n    >>> s = pd.Series([1, 2, 2])\n    >>> s\n    0    1\n    1    2\n    2    2\n    dtype: int64\n    >>> s.to_set()\n    {1, 2}\n    \"\"\"\n\n    return set(s.unique())\n", "path": "dtoolkit/accessor/series/to_set.py"}], "after_files": [{"content": "import pandas as pd\n\nfrom dtoolkit.accessor.register import register_index_method\n\n\n@register_index_method\ndef to_set(index: pd.Index) -> set:\n    \"\"\"\n    Return a :keyword:`set` of the values.\n\n    A sugary syntax wraps :keyword:`set`::\n\n        set(index)\n\n    Different to :meth:`~pandas.Index.unique`, it returns :class:`~pandas.Index`.\n\n    Returns\n    -------\n    set\n\n    See Also\n    --------\n    pandas.Index.unique\n    dtoolkit.accessor.series.to_set\n\n    Examples\n    --------\n    >>> import dtoolkit.accessor\n    >>> import pandas as pd\n    >>> i = pd.Index([1, 2, 2])\n    >>> i\n    Int64Index([1, 2, 2], dtype='int64')\n    >>> i.to_set()\n    {1, 2}\n    \"\"\"\n\n    return set(index.unique())\n", "path": "dtoolkit/accessor/index/to_set.py"}, {"content": "import pandas as pd\n\nfrom dtoolkit.accessor.register import register_series_method\n\n\n@register_series_method\ndef to_set(s: pd.Series) -> set:\n    \"\"\"\n    Return a :keyword:`set` of the values.\n\n    A sugary syntax wraps :keyword:`set`::\n\n        set(s)\n\n    Different to :meth:`~pandas.Series.unique`, it returns :class:`~numpy.ndarray`.\n\n    Returns\n    -------\n    set\n\n    See Also\n    --------\n    pandas.Series.unique\n    dtoolkit.accessor.index.to_set\n\n    Examples\n    --------\n    >>> import dtoolkit.accessor\n    >>> import pandas as pd\n    >>> s = pd.Series([1, 2, 2])\n    >>> s\n    0    1\n    1    2\n    2    2\n    dtype: int64\n    >>> s.to_set()\n    {1, 2}\n    \"\"\"\n\n    return set(s.to_list())\n", "path": "dtoolkit/accessor/series/to_set.py"}]}