Skip to content

Replace pkg_resources with __file__/glob combination - #458

Merged
ddemidov merged 1 commit into
stretchfrom
issue-456
Apr 30, 2018
Merged

ddemidov merged 1 commit into
stretchfrom
issue-456

Conversation

@ddemidov

Copy link
Copy Markdown
Member

This should reduce time to import ev3dev.fonts. See #456.
Would be nice if anyone could confirm this.

@ddemidov

Copy link
Copy Markdown
Member Author

This works on my machine, but I did not test the actual performance impact on the ev3.

@ndward

ndward commented Apr 23, 2018

Copy link
Copy Markdown

Is this issue referring to the latest Stretch image (22 April 2018)? I'm not able to get a connection from my PC to the EV3 with that image. The EV3 says it is connected but neither VS Code nor SFTP Net Drive can connect to it. Just me?

@ddemidov

Copy link
Copy Markdown
Member Author

This implementation should work both for the jessie and stretch images. I hope you would see an improvement on whatever system you used here: ev3dev/ev3dev#1022 (comment).

@ddemidov

Copy link
Copy Markdown
Member Author

Just checked, and this works on the latest stretch image. The following script was used for testing:

from ev3dev2.fonts import *

Before the patch:

time python3 tf.py

real	0m32.798s
user	0m24.747s
sys	0m0.603s

After the patch:

time python3 tf.py

real	0m5.543s
user	0m4.168s
sys	0m0.266s

@ddemidov
ddemidov merged commit c968ab1 into stretch Apr 30, 2018
@ddemidov
ddemidov deleted the issue-456 branch April 30, 2018 07:24
@ensonic

ensonic commented Jun 26, 2018

Copy link
Copy Markdown
Contributor

In jessie ev3dev-lang-.python has the same /usr/lib/python3/dist-packages/ev3dev/fonts/__init__.py. I've applied the same changes, but did not see the speedup. Do we have less fonts?

$ cat tf.py
from ev3dev.fonts import *
$ time python3 tf.py 

real	0m14.355s
user	0m12.070s
sys	0m0.500s
$ sudo mv new.py /usr/lib/python3/dist-packages/ev3dev/fonts/__init__.py
$ time python3 tf.py 

real	0m13.907s
user	0m11.960s
sys	0m0.500s
$ ls -1  /usr/lib/python3/dist-packages/ev3dev/fonts/ | wc -l
402

FInally why do we bother to build the 'pbm_file' in load() if we don't use it ever?

@ddemidov

ddemidov commented Jul 9, 2018

Copy link
Copy Markdown
Member Author

Do we have less fonts?

We package the fonts ourselves, so it should be the same both for stretch and jessie.

I've applied the same changes, but did not see the speedup

Can you add some prints to the new __init__.py to make sure you are actually using it?

FInally why do we bother to build the 'pbm_file' in load() if we don't use it ever?

I don't remember why exactly, but I think it was used implicitly. Can you try to comment that out and see if the fonts still work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants