CLN: get_flattened_iterator
State: closed

- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`

Refactor to just a single function


Labels:
name: Clean

Comments:
LGTM
can you also run the groupby asvs (in particular the ones that exercise the full int64 cardinaility) to assure no perf diffs.
This small benchmark shows no performance degradation:

```
In [1]: df = pd.DataFrame({'a': list(range(1000)) * 2, 'b': list(range(1000)) * 2})

In [4]: %timeit df.groupby('a').sum()
1.06 ms ± 74.1 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) <--PR


In [4]: %timeit df.groupby('a').sum()
1.1 ms ± 71.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) <-- master
```

I'm getting this error when trying to run the asvs locally
```
STDERR -------->
   /Users/matthewroeschke/pandas-mroeschke/asv_bench/env/a36d556a9d1611aba4092dc48036d261/lib/python3.6/site-packages/setuptools/distutils_patch.py:26: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
     "Distutils was imported before Setuptools. This usage is discouraged "
   warning: pandas/_libs/groupby.pyx:1130:26: Unreachable code
   pandas/_libs/parsers.c:49607:52: error: code will never be executed [-Werror,-Wunreachable-code]
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                                      ^~~~
   pandas/_libs/parsers.c:49607:38: note: silence by adding parentheses to mark code as explicitly dead
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                        ^
                                        /* DISABLES CODE */ ( )
   1 error generated.
   pandas/_libs/ops_dispatch.c:3877:52: error: code will never be executed [-Werror,-Wunreachable-code]
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                                      ^~~~
   pandas/_libs/ops_dispatch.c:3877:38: note: silence by adding parentheses to mark code as explicitly dead
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                        ^
                                        /* DISABLES CODE */ ( )
   1 error generated.
   pandas/_libs/tslibs/offsets.c:89935:52: error: code will never be executed [-Werror,-Wunreachable-code]
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                                      ^~~~
   pandas/_libs/tslibs/offsets.c:89935:38: note: silence by adding parentheses to mark code as explicitly dead
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                        ^
                                        /* DISABLES CODE */ ( )
   1 error generated.
   pandas/_libs/tslibs/parsing.c:39517:52: error: code will never be executed [-Werror,-Wunreachable-code]
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                                      ^~~~
   pandas/_libs/tslibs/parsing.c:39517:38: note: silence by adding parentheses to mark code as explicitly dead
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                        ^
                                        /* DISABLES CODE */ ( )
   1 error generated.
   pandas/_libs/tslibs/period.c:44813:52: error: code will never be executed [-Werror,-Wunreachable-code]
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                                      ^~~~
   pandas/_libs/tslibs/period.c:44813:38: note: silence by adding parentheses to mark code as explicitly dead
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                        ^
                                        /* DISABLES CODE */ ( )
   1 error generated.
   pandas/_libs/tslibs/timedeltas.c:43722:52: error: code will never be executed [-Werror,-Wunreachable-code]
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                                      ^~~~
   pandas/_libs/tslibs/timedeltas.c:43722:38: note: silence by adding parentheses to mark code as explicitly dead
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                        ^
                                        /* DISABLES CODE */ ( )
   1 error generated.
   pandas/_libs/tslibs/timestamps.c:41544:52: error: code will never be executed [-Werror,-Wunreachable-code]
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                                      ^~~~
   pandas/_libs/tslibs/timestamps.c:41544:38: note: silence by adding parentheses to mark code as explicitly dead
           } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
                                        ^
                                        /* DISABLES CODE */ ( )
   1 error generated.
   error: command 'gcc' failed with exit status 1

·· Failed to build the project and import the benchmark suite.
```
If on a Mac I think you need to change the Python version in the ASV conf for it to compile. I think there’s an open issue to update that

Sent from my iPhone

> On Aug 6, 2020, at 10:10 AM, Matthew Roeschke <notifications@github.com> wrote:
> 
> ﻿
> This small benchmark shows no performance degradation:
> 
> In [1]: df = pd.DataFrame({'a': list(range(1000)) * 2, 'b': list(range(1000)) * 2})
> 
> In [4]: %timeit df.groupby('a').sum()
> 1.06 ms ± 74.1 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) <--PR
> 
> 
> In [4]: %timeit df.groupby('a').sum()
> 1.1 ms ± 71.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) <-- master
> I'm getting this error when trying to run the asvs locally
> 
> STDERR -------->
>    /Users/matthewroeschke/pandas-mroeschke/asv_bench/env/a36d556a9d1611aba4092dc48036d261/lib/python3.6/site-packages/setuptools/distutils_patch.py:26: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
>      "Distutils was imported before Setuptools. This usage is discouraged "
>    warning: pandas/_libs/groupby.pyx:1130:26: Unreachable code
>    pandas/_libs/parsers.c:49607:52: error: code will never be executed [-Werror,-Wunreachable-code]
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                                       ^~~~
>    pandas/_libs/parsers.c:49607:38: note: silence by adding parentheses to mark code as explicitly dead
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                         ^
>                                         /* DISABLES CODE */ ( )
>    1 error generated.
>    pandas/_libs/ops_dispatch.c:3877:52: error: code will never be executed [-Werror,-Wunreachable-code]
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                                       ^~~~
>    pandas/_libs/ops_dispatch.c:3877:38: note: silence by adding parentheses to mark code as explicitly dead
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                         ^
>                                         /* DISABLES CODE */ ( )
>    1 error generated.
>    pandas/_libs/tslibs/offsets.c:89935:52: error: code will never be executed [-Werror,-Wunreachable-code]
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                                       ^~~~
>    pandas/_libs/tslibs/offsets.c:89935:38: note: silence by adding parentheses to mark code as explicitly dead
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                         ^
>                                         /* DISABLES CODE */ ( )
>    1 error generated.
>    pandas/_libs/tslibs/parsing.c:39517:52: error: code will never be executed [-Werror,-Wunreachable-code]
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                                       ^~~~
>    pandas/_libs/tslibs/parsing.c:39517:38: note: silence by adding parentheses to mark code as explicitly dead
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                         ^
>                                         /* DISABLES CODE */ ( )
>    1 error generated.
>    pandas/_libs/tslibs/period.c:44813:52: error: code will never be executed [-Werror,-Wunreachable-code]
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                                       ^~~~
>    pandas/_libs/tslibs/period.c:44813:38: note: silence by adding parentheses to mark code as explicitly dead
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                         ^
>                                         /* DISABLES CODE */ ( )
>    1 error generated.
>    pandas/_libs/tslibs/timedeltas.c:43722:52: error: code will never be executed [-Werror,-Wunreachable-code]
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                                       ^~~~
>    pandas/_libs/tslibs/timedeltas.c:43722:38: note: silence by adding parentheses to mark code as explicitly dead
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                         ^
>                                         /* DISABLES CODE */ ( )
>    1 error generated.
>    pandas/_libs/tslibs/timestamps.c:41544:52: error: code will never be executed [-Werror,-Wunreachable-code]
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                                       ^~~~
>    pandas/_libs/tslibs/timestamps.c:41544:38: note: silence by adding parentheses to mark code as explicitly dead
>            } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
>                                         ^
>                                         /* DISABLES CODE */ ( )
>    1 error generated.
>    error: command 'gcc' failed with exit status 1
> 
> ·· Failed to build the project and import the benchmark suite.
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub, or unsubscribe.

thanks @mroeschke