Status: Won't Fix
Fix Version/s: None
In the review to
DM-16535, John Parejko requested that the flatten function, which converts an iterable of mixed scalars and iterables to a list of scalars, be made a public function in utils so that it could be used elsewhere.
Given that "flatten" is a very common name in the Stack, perhaps we should choose a different name to avoid confusion.
Good question. My first thought is returning a sequence (list is the simplest). I suspect, but am not certain, the situations where we would like to use this would not involve much memory pressure.
I would ask for broader input (say, slack#dm) on that question.
Hi John Parejko, can you please review this? Thanks!
See comments (from me and others) on the PR: at least fix the infinite string iteration. It may well be worth making it use a generator; see my stackoverflow link.
As recommended in the review, I decided not to merge these changes because lsst.verify.gen2tasks is the only client. If somebody else (e.g., John Parejko) finds they also need this functionality, then we can create a new ticket and re-submit the commits there.
(Before closing the PR I both fixed the infinite recursion on strings, and explicitly disallowed mapping types. Many thanks for catching those bugs!)
Question for John Parejko: should lsst.utils.flatten stick to returning a sequence, or would making it a generator be useful?