Skip to content

Commit 6242836

Browse files
author
Drew O'Meara
committed
comment and cruft cleanup
1 parent 6a0c11e commit 6242836

2 files changed

Lines changed: 15 additions & 30 deletions

File tree

examples/multi-ctx/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func main() {
2020

2121
// The total job count implies a fixed amount of work.
2222
// The number of workers is how many py.Ctx (in concurrent goroutines) to pull jobs off the queue.
23-
// One worker does all the work serially while N number of workers will (ideally) divide that up.
23+
// One worker does all the work serially while N number of workers will (ideally) divides up.
2424
totalJobs := 20
2525

2626
for i := 0; i < 10; i++ {

py/run.go

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ const (
1212
SingleMode CompileMode = "single" // Compile a single (interactive) statement
1313
)
1414

15-
type RunFlags int32
16-
17-
const (
18-
// RunOpts.FilePath is intelligently interpreted to load the appropriate pyc object (otherwise new code is generated from the implied .py file)
19-
SmartCodeAcquire RunFlags = 0x01
20-
)
21-
2215
// Ctx is gpython virtual environment instance ("context"), providing a mechanism
2316
// for multiple gpython interpreters to run concurrently without restriction.
2417
//
@@ -51,45 +44,37 @@ type Ctx interface {
5144
Store() *Store
5245
}
5346

54-
const (
55-
SrcFileExt = ".py"
56-
CodeFileExt = ".pyc"
57-
)
58-
59-
type StdLib int32
60-
61-
const (
62-
Lib_sys StdLib = 1 << iota
63-
Lib_time
64-
65-
CoreLibs = Lib_sys | Lib_time
66-
)
67-
47+
// CompileOpts specifies options for high-level compilation.
6848
type CompileOpts struct {
6949
UseSysPaths bool // If set, sys.path will be used to resolve relative pathnames
70-
CurDir string // If non-nil, this is the path of the current working directory. If nil, os.Getwd() is used.
50+
CurDir string // If non-empty, this is the path of the current working directory. If empty, os.Getwd() is used.
7151
}
7252

53+
// CompileOut is the output object of high-level compilation, e.g. ResolveAndCompile()
7354
type CompileOut struct {
7455
SrcPathname string // Resolved pathname the .py file that was compiled (if applicable)
7556
PycPathname string // Pathname of the .pyc file read and/or written (if applicable)
7657
FileDesc string // Pathname to be used for a a module's "__file__" attrib
7758
Code *Code // Read/Output code object ready for execution
7859
}
7960

80-
// Can be changed during runtime and will \play nice with others using DefaultCtxOpts()
81-
var CoreSysPaths = []string{
61+
// DefaultCoreSysPaths specify default search paths for module sys
62+
// This can be changed during runtime and plays nice with others using DefaultCtxOpts()
63+
var DefaultCoreSysPaths = []string{
8264
".",
8365
"lib",
8466
}
8567

86-
// Can be changed during runtime and will \play nice with others using DefaultCtxOpts()
87-
var AuxSysPaths = []string{
68+
// DefaultAuxSysPaths are secondary default search paths for module sys.
69+
// This can be changed during runtime and plays nice with others using DefaultCtxOpts()
70+
// They are separated from the default core paths since they the more likley thing you will want to completely replace when using gpython.
71+
var DefaultAuxSysPaths = []string{
8872
"/usr/lib/python3.4",
8973
"/usr/local/lib/python3.4/dist-packages",
9074
"/usr/lib/python3/dist-packages",
9175
}
9276

77+
// CtxOpts specifies fundamental environment and input settings for creating a new py.Ctx
9378
type CtxOpts struct {
9479
SysArgs []string // sys.argv initializer
9580
SysPaths []string // sys.path initializer
@@ -100,9 +85,9 @@ var (
10085
// Calling this ensure that you future proof you code for suggested/default settings.
10186
DefaultCtxOpts = func() CtxOpts {
10287
opts := CtxOpts{
103-
SysPaths: CoreSysPaths,
88+
SysPaths: DefaultCoreSysPaths,
10489
}
105-
opts.SysPaths = append(opts.SysPaths, AuxSysPaths...)
90+
opts.SysPaths = append(opts.SysPaths, DefaultAuxSysPaths...)
10691
return opts
10792
}
10893

@@ -115,7 +100,7 @@ var (
115100
Compile func(src, srcDesc string, mode CompileMode, flags int, dont_inherit bool) (*Code, error)
116101
)
117102

118-
// Resolves the given pathname, compiles as needed, and runs that code in the given module, returning the Module to indicate success.
103+
// RunFile resolves the given pathname, compiles as needed, and runs that code in the given module, returning the Module to indicate success.
119104
// If inModule is a *Module, then the code is run in that module.
120105
// If inModule is nil, the code is run in a new __main__ module (and the new Module is returned).
121106
// If inModule is a string, the code is run in a new module with the given name (and the new Module is returned).

0 commit comments

Comments
 (0)