|
|
#1 |
|
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 448
Karma: 3000000
Join Date: Nov 2020
Device: none
|
Python optimize level
I'm trying to use spaCy's transformer model in calibre, it uses the "transformer" package which has a line code uses docstring: https://github.com/huggingface/trans..._base.py#L3646
But calibre's optimize level is 2, which removes docstrings. How can I change this optimize level to a lower level? |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,607
Karma: 28548974
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You cant, it's hardcoded, IIRC see the code in the bypy project that launches the interpreter.
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 448
Karma: 3000000
Join Date: Nov 2020
Device: none
|
I'll try to run the code in another Python interpreter to get around this. Thanks for your quick reply.
|
|
|
|
|
|
#4 |
|
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 448
Karma: 3000000
Join Date: Nov 2020
Device: none
|
Look like it's this line: https://github.com/kovidgoyal/bypy/b...-freeze.h#L795 and this line https://github.com/kovidgoyal/bypy/b..._init__.py#L35
Run code in the system Python adds more complexity than I thought before. Would you consider set the optimize level to 1? Level 2 does the same thing as level 1 except remove docstrings. Last edited by xxyzz; 11-06-2022 at 07:59 PM. |
|
|
|
|
|
#5 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,607
Karma: 28548974
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I'm afraid not sorry. Increasing the optimization level is a benefit to all calibre code, I am not willing to reduce it for one use case. Python code that relies on docstrings for anything other than documentation/tests is broken and needs to be fixed.
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 448
Karma: 3000000
Join Date: Nov 2020
Device: none
|
Alright, I'll try to run the code in the system Python interpreter. Thanks for your help.
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Python 2 to Python 3, Polyglot & Plugins | DaltonST | Calibre | 18 | 04-24-2019 12:10 AM |
| How can I optimize the use of my iPad | bettyallen | Apple Devices | 2 | 08-16-2011 11:27 PM |
| PRS-650 Optimize PDF | UpSpin | Sony Reader | 7 | 05-20-2011 06:14 PM |
| do you try to optimize for different devices? | sarah_pnix | ePub | 5 | 02-16-2011 05:05 AM |
| Optimize any2epub | JeffElkins | Calibre | 4 | 10-17-2008 03:31 PM |