Closed Avasam closed 2 years ago
Hey! Sorry for the delay in my reply. These days, I have very limited time and access to all my "things".
Thank you so much for your time and help. I can not test, extend to all other methods and merge this all at the moment, I hope it's not a problem for you (if it is, just let me know and I will do my best!). Besides, I have to carefully read your advices and your code to understand everything. Bear in mind I have never studied nor worked in Python (I learned Python, very recently, and mainly on stackoverflow, HAHAHAHA!, Let's say it's sad but true!), so this all is really helpful to me!!!
Regarding your comments:
Apart from this all, I think your code is fantastic and will work perfectly! Thank you for your help and "instruction".
__remove_bad_windows
is indeed a generator. But in this case it's more used as a workaround to filter a list using try-except. If it's used inside a list comprehension, it still has to yield all values. Since I knew I'd only have to check for 1-2 items in most cases, it was important I don't get the whole list. Just something to keep in mind for possible future improvements. And you are right it's totally reusable.Quartz returns the list of apps in "last to first focused" order, which in many cases may not match "upper".
I think it's worth implementing that way. Unfortunately I haven't had time, (and won't really have for the next 2 weeks) to look into it and read some apple documentation. So I threw together a very naïve implementation (maybe a NotImplementedError
might be better at this point ? ). I've also hit other blockers with other module on Mac anyway for the project I'm working on. So feel free to edit that part/suggest code improvements.
No hurry on merging, I just install directly from my fork !
Understood and agree. I will complete that function on macOS as soon as I can, don't worry.
Have some nice days!
Closes #20. Incidentally Fixes #18
Some notes:
append
. (difference in performance is small, but it's there, it's also best practice)map
,filter
,reduce
, etc., as they are considered non-pythonic. They were nearly removed from python3. The difference in performance is marginal.Unknown
types along the way. Didn't wanna scope creep too much, so only touched functions related to this PR.Win32Window(hwnd) if hwnd else None
getWindowsAt
? BecausegetAllWindows
iterates over the entire list to remove bad windows. And often the window we'll be interested in is going to be at the very end of the clientliststack. This has noticeable performance implications at it scales with the number of windows open (5 windows --> ~5 times slower, 2 windows --> ~2 times slower). Benchmarks:Iterator + break loop early, at 5 windows
Note this means there's a performance improvement to be had everywhere we get all windows. I don't think
getAllWindows
itself should return a generator (as it's public API I think it's ok to make it a list and be consistent with the rest of the exposed methods). But they could all use a__getAllWindowsGenerator
under the hood.I didn't want to scope creep this PR, so I'll leave this for another time.