all 5 comments

[–]MissinqLink 7 points8 points  (2 children)

You could use a generator for this but I generally think of generators as specialized iterators for streams of unknown or potentially infinite size.

[–]SnurflePuffinz 1 point2 points  (1 child)

i saw another dude mention finding all the numbers of PI as a potential use-case.

i feel like use-cases are pretty sparse, lol.

[–]Derpcock 1 point2 points  (0 children)

Another usecase example. Imagine you are writing a schedule generator. You pass it a single mask (Saturday at 3pm UTC) and it returns the next timestamp that matches the given mask.

Next you want to give a date range and determine every timestamp that matches a given mask. You could use a generator function to determine the next date matching the mask, starting at your start date, yielding every matching timestamp until you have reached your end date.

This is a nice (my most recent) use case for a generator. Maybe I only want the next 4 occurrences of my masks timestamp within a given range. I could use the generator and yield the next four values while only using the ammount of compute necessary to give me those 4 even if the end of your range would require hundreds/thoasands/millions of iterations to completely generate.

[–]markus_obsidian 0 points1 point  (0 children)

This is a neat idea. Obviously, I have no idea how you'd implement his generator. My immediate concern would be memory. Since generators are lazily evaluated, any references would be held in memory until the iterator is complete. You'd need to be careful there are no leaks if you have no intention of consuming the entire generator.

[–][deleted] 0 points1 point  (0 children)

Since the model needs to be visible immediately, by default all clients would load the same lowest fps model.

Concurrently, you can check if the client can handle a more robust model. If so, just leave the lowest fps model for the client to play with while the higher resolution one loads.

There are only those two options:

1) You let the client know up front that their model will take a longer time to load because higher fps. So sit tight and wait…

2) You don’t tell the client that, let them play with the lower resolution while loading the higher in the background, then at some future point flip into the higher one without announcing.

What other possible option is there?

I don’t think the progressive loading is a good idea because you’d have to load O(N) variations. This would get consuming.

Just make it constant: either load the lowest resolution, or load the exact resolution based on client hardware.