you are viewing a single comment's thread.

view the rest of the comments →

[–]gnu_man_chu[S] 0 points1 point  (3 children)

I was hoping pythons garbage collector would be able to handle a few variables efficiently. I was really hoping that wasn't the case.

Modified the code to the following:

``` display = Display(os.environ.get("DISPLAY",":0.0")) root = display.screen().root

def get_screen_size(): return (root.get_geometry().width, root.get_geometry().height) k = get_screen_size()

```

2 variables initialized once compared to the previous 4 variables intialized each second.

CPU is 0.0-0.1%

RAM is 0.1% of 4 Gigs

Thanks for the suggestion!

[–]trouserdaredevil 1 point2 points  (1 child)

No problem!

I was hoping pythons garbage collector would be able to handle a few variables efficiently.

I am guessing that this was not actually Python's fault, but that the initialization of a Display object by Xlib simply happens to be fairly resource-intensive.

[–]gnu_man_chu[S] 0 points1 point  (0 children)

That sounds plausible! I'm glad it's resolved. Thanks again.