embray / gappy

Python interface to GAP
GNU General Public License v3.0
13 stars 5 forks source link

Better handling of global Gap instance #5

Open embray opened 3 years ago

embray commented 3 years ago

The Gap class is the core wrapper class for accessing the GAP interpreter. Only one instance can be used at a time, for now, since only one GAP interpreter instance can exist in a single process. The default Gap instance gappy.gap is instantiated with some default parameters that will work in many cases. However, it's possible to instantiate one's own instance with different parameters by instantiating a Gap in the normal way. See 640dac66fe483cf6cdb7d68de141380b973b807d

As d66f40310b2d4f7535743ff76deb6cd298be730c points out, if a custom Gap is instantiated it's no longer possible to use the default gap.

I would prefer that Gap were a singleton, and that gappy.gap always points to the active instance. Calling Gap() will only update the initialization arguments in the case where the default instance has not already instantiated the GAP interpreter.

OTOH, maybe it should remain possible to have multiple simultaneous Gap instances, in case it's ever possible to have multiple GAP sub-interpreters. I don't know if/when that will ever be possible though.