Skip to content

Commit a17ebde

Browse files
committed
move foundation import to .run
- inexplicably it cuts startup time in half
1 parent dc4b9a5 commit a17ebde

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

plotdevice/lib/cocoa.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@
4646
NSToolbarItem, NSTrackingActiveInActiveApp, NSTrackingArea, NSTrackingMouseEnteredAndExited, \
4747
NSUnboldFontMask, NSUnitalicFontMask, NSUnionRect, NSView, NSViewFrameDidChangeNotification, \
4848
NSWindow, NSWindowBackingLocationVideoMemory, NSWindowController, NSWorkspace, NSKernAttributeName
49-
from Foundation import *
49+
from Foundation import CIAffineTransform, CIColorMatrix, CIContext, CIFilter, CIImage, \
50+
CIVector, Foundation, NO, NSAffineTransform, NSAffineTransformStruct, \
51+
NSAttributedString, NSAutoreleasePool, NSBundle, NSData, NSDate, NSDateFormatter, \
52+
NSFileCoordinator, NSFileHandle, NSFileHandleDataAvailableNotification, NSIntersectionRange, \
53+
NSHeight, NSInsetRect, NSIntersectionRect, NSLocale, NSLog, NSMacOSRomanStringEncoding, \
54+
NSMakeRange, NSMidX, NSMidY, NSMutableAttributedString, NSMutableData, NSNotificationCenter, NSObject,\
55+
NSOffsetRect, NSOperationQueue, NSPoint, NSRect, NSRectFromString, NSSelectorFromString, \
56+
NSSize, NSString, NSStringFromRect, NSTimeZone, NSTimer, NSURL, NSUserDefaults, \
57+
NSUTF8StringEncoding, NSWidth
5058
from LaunchServices import kUTTypePNG, kUTTypeJPEG, kUTTypeGIF, kUTTypeTIFF
5159
from WebKit import WebView
5260
from objc import IBOutlet, IBAction

plotdevice/lib/io.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import objc, os, re
2-
# from Foundation import *
32

43
import cIO
54
for cls in ["AnimatedGif", "Pages", "SysAdmin", "Video"]:

plotdevice/run/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import sys, site
2-
from os.path import abspath, dirname, relpath, exists, join
2+
from os.path import abspath, dirname, exists, join
33
from subprocess import call, getoutput
44

55
try:
66
# test the sys.path by attempting to load a PyObjC submodule...
7-
import objc
7+
from Foundation import *
88
except ImportError:
99
deps_dir = join(dirname(__file__), '../../app/deps')
1010
if exists(deps_dir):
@@ -26,12 +26,10 @@
2626
# use the venv's site directory
2727
site_path = getoutput('%s/bin/python3 -c "import site; print(site.getsitepackages()[0])"' % venv_dir)
2828
site.addsitedir(site_path)
29-
import objc
29+
from Foundation import *
3030
else:
3131
from pprint import pformat
3232
missing = "Searched for PyObjC libraries in:\n%s\nto no avail..."%pformat(sys.path)
33-
if exists('%s/../../app/info.plist'%dirname(__file__)):
34-
missing += '\n\nBuild the plotdevice module with `python setup.py build\' before attempting import it.'
3533
raise RuntimeError(missing)
3634

3735
# pull in the encoding-pragma detector

0 commit comments

Comments
 (0)