So it seems my computer can execute commands faster than
python can pipe them.
I am pretty sure that writing desklets in C has its
advantages over Python in term of speed, but I do not think
your diagnostic to be accurate. The fact that things are
smoother with C is no indication whatsoever that the problem
is IO-bound. I put quite a bit on syntatic sugar in my demo
Python bindings to give command a pythonic look and feel, and
it comes at a cost, as many intermediate values are computed
on the fly for every command submitted...
I wrote this desklet in both python and C, both using
pipes, and the animation in the C version is much
smoother
I do not know what you tried animating, but direct mode of
execution will never be suited with adesklets for any kind of
smooth (i.e. regularily spaced in time) animation, the reason
being that the interpreter is by nature asynchroneous, and
you cannot (should not) rely on it to get precisely timed
roundtrip between successive commands.That's why adesklets
have an indirect mode of execution, giving the possibility to
'replay' a variation of pre-registered commands in a single
invocation (see
test/fading.py for instance). You most
probably get smoother results because your C desklet does
very little work compared to the Python version to issue
commands, hence a lower-overhead, and a far decreased
possibility to be put to sleep by the scheduler at
inappropriate times; that doesn't mean the effect you seek
could not be achieved in other ways.
Anyway, a library wouldn't be pointless at all. adesklets
is still needed for providing consistent session management
and dealing with xlib
Yes... I guess you are right about that, I overlooked the
session management aspect. As for dealing with xlib, it is
pretty simple regarless of adesklets.
And it wouldn't be too hard to implment the library, since
like you said most calls would go to imlib2
Almost true. The problem is that we would imperatively need
to wrap all calls anyway, because imlib2 provides no
automated regitrering of drawable dirty spots; for every call
to imlib2, we need to make sure we know what was changed on
screen. Refreshing the complete window at each step is simply
not an option performance-wise. A lot of the
pseudo-transparency management details are also hidden
everywhere. So, while it is very straigthforward to use
imlib2 from C knowing your specific task, it is not that
simple to wrap a generic dynamic console.
Moreover, making a good truely single-process C library would
go deeper than the pipe issue, as synchroneous/asynchroneous
API are very different beasts, so it would not be a simple
matter of wrapping actual calls in a C-level library, tons of
small details would need to be reconsidered.
It would also make it easier to write a post-it notes
desklet that might use GTK or FLTK
Well, it is your take on it. These things are in my opinion
far easier in higher-level languages, but let's not start
another war. ;-)
an adesklets library would just make it a lot easier to
write a bunch of cool new deskets that wouldn't be
otherwise possible through the interpreter.
Granted, I am pretty sure you are right about C being able to
produce a broader class of desklets, namely those with
animations that cannot be precomputed in any reasonnable way
(far less frequent than one might think): for the rest, using
indirect mode does the trick. As for desklets being easier to
write in C, regardless of a library, well, I guess it pretty
much depends on your background. ;-)