Make app launch faster
@@ -596,22 +596,8 @@ void init_cv2() {
#if MAIN || WIDGET
int initialize_python(int argc, char *argv[]) {
- // MARK: - Init builtins
- #if !(TARGET_IPHONE_SIMULATOR)
- #if MAIN
- init_numpy();
- init_matplotlib();
- init_pandas();
- init_biopython();
- init_lxml();
- init_scipy();
- init_sklearn();
- init_skimage();
- init_pywt();
- init_cv2();
- init_cffi();
- #endif
- init_pil();
+ #if MAIN && !WIDGET
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
#endif
NSBundle *pythonBundle = Python.shared.bundle;
@@ -635,6 +621,24 @@ int initialize_python(int argc, char *argv[]) {
putenv((char *)[[NSString stringWithFormat:@"SSL_CERT_FILE=%@", certPath] UTF8String]);
#endif
+ // MARK: - Init builtins
+ #if !(TARGET_IPHONE_SIMULATOR)
+ #if MAIN
+ init_numpy();
+ init_matplotlib();
+ init_pandas();
+ init_biopython();
+ init_lxml();
+ init_scipy();
+ init_sklearn();
+ init_skimage();
+ init_pywt();
+ init_cv2();
+ init_cffi();
+ #endif
+ init_pil();
+ #endif
+
// MARK: - Init Python
Py_SetPythonHome(Py_DecodeLocale([pythonBundle.bundlePath UTF8String], NULL));
Py_Initialize();
@@ -647,11 +651,13 @@ int initialize_python(int argc, char *argv[]) {
}
PySys_SetArgv(argc, python_argv);
- #if MAIN
- [Python.shared importPytoLib];
-
// MARK: - Start the REPL that will contain all child modules
[Python.shared runScriptAt:[[NSBundle mainBundle] URLForResource:@"scripts_runner" withExtension:@"py"]];
+ #if MAIN && !WIDGET
+ });
+ #endif
+
+ #if MAIN
@autoreleasepool {
return UIApplicationMain(argc, argv, NULL, NSStringFromClass(AppDelegate.class));
