11-06-2022, 08:35 AM | #1 |
Evangelist
Posts: 413
Karma: 2666666
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? |
11-06-2022, 08:37 AM | #2 |
creator of calibre
Posts: 43,866
Karma: 22666666
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 | |
|
11-06-2022, 08:47 AM | #3 |
Evangelist
Posts: 413
Karma: 2666666
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.
|
11-06-2022, 06:51 PM | #4 |
Evangelist
Posts: 413
Karma: 2666666
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. |
11-06-2022, 08:55 PM | #5 |
creator of calibre
Posts: 43,866
Karma: 22666666
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 | |
|
11-06-2022, 09:53 PM | #6 |
Evangelist
Posts: 413
Karma: 2666666
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 |