Timeline for Intersection of sorted lists
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 6, 2019 at 11:09 | history | edited | Graipher | CC BY-SA 4.0 |
added 273 characters in body
|
Dec 6, 2019 at 3:35 | comment | added | kyrill |
I said I can consume elements on the fly if I wanted to, not that I do. This is easy to see and I don't feel the need to modify my original function to make it any more obvious. Anyhow, which itertools functions are you talking about?
|
|
Dec 6, 2019 at 2:57 | comment | added | user179245 |
@kyrill Then you definitely should modify your function to take iterables and yield values instead while utilizing the itertools functions; they're mostly written in C and this is the kind of situation they're used for. It's much cleaner and prevents all the clumsy store-keeping revolving around lists.
|
|
Dec 6, 2019 at 2:51 | comment | added | kyrill |
@Voile I think you got me wrong. I don't want to avoid C; I want to avoid creating a set if I already have a list which may be large. Furthermore, using my original approach as opposed to a set-based one, I can consume elements on the fly, so I can even process infinite iterables (assuming they are sorted).
|
|
Dec 6, 2019 at 2:42 | comment | added | user179245 |
@kyrill: Using functions implemented in C instead of doing everything in Python is the best practice because removes the interpreter overhead; more-itertools recipes do this for all the functions inside. Why are you trying to avoid best practice?
|
|
Dec 5, 2019 at 14:04 | comment | added | kyrill |
3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]
|
|
Dec 5, 2019 at 13:53 | comment | added | Graipher | @kyrill: Interesting results. Which Python version did you use? The one I used is 3.6.9. | |
Dec 5, 2019 at 13:47 | comment | added | kyrill |
Interesting; I ran your inputs with timeit.Timer.autorange and got these results. Also, keep in mind that my method as well as alexyorke's is implemented in pure Python, whereas set and sorted are implemented in C, that's why it's so fast.
|
|
Dec 5, 2019 at 13:26 | history | edited | Graipher | CC BY-SA 4.0 |
added 226 characters in body
|
Dec 5, 2019 at 11:38 | history | answered | Graipher | CC BY-SA 4.0 |