#18555: Pickling and otherwise enhancing global options
-------------------------------------+-------------------------------------
       Reporter:  andrew.mathas      |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.8
      Component:  interfaces         |   Resolution:
       Keywords:  days78, options    |    Merged in:
        Authors:  Andrew Mathas      |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  public/misc/pickling_global_options-18555|  
3f5e0e91e2289dcee18ad56b30c6884f9d26c890
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Old description:

> Instances of the
> [http://doc.sagemath.org/html/en/reference/structure/sage/structure/global_options.html
> GlobalOptions] class in `sage.structure.global_options` do not pickle,
> which is annoying and causes various problems. (This is a defect.)
>
> In addition, when the `GlobalOptions` class was introduced it was
> suggested in [https://groups.google.com/forum/#!searchin/sage-
> devel/globabloptions/sage-devel/7ApZgwBTU4U/Qe6QoeuYgvAJ sage-dev] that
> it "would be nice" if we could implement the syntax used in the IPython
> configuration:
> {{{
>
>     A.options.foobar = 1
>
> in addition to
>
>     A.options(foobar=1)
> }}}
>  This ticket implements both of these features and, in addition, makes it
> possible to construct options classes dynamically.
>
> The pickling is done by adding an extra `module` argument to the
> `GlobalOptions` that specifies the module which contains the class that
> the options are attached -- `name` of of the class defaults to the name
> of the options class but this can be explicitly set using the
> `options_class` argument. The options class is assumed to have an
> `options` method, and this is used to unpickle a pickle for an options
> class. `GlobalOptions` that do not arise as options methods for standard
> sage classes cannot be unpickled. The reason why the name of the module
> and class are passed, as strings, to `GlobalOptions` rather than the
> actual class is that this approach allows the options to be constructed
> during the initialisation of the (instance of the) class and, in turn,
> this allows the class to dynamically construct their options classes.
>
> As suggested on sage-dev I have also renamed all of the global_options
> methods simply as options, with the global_options variants being
> deprecated. The "stand-alone" options classes such as
> `PartitionOoptions`, `TableauxOptions`, ... have also been deprecated
> and, instead, put inside their "parent" classes. This is cleaned up the
> code a little and it seems to speed up the sage start-up time.

New description:

 Instances of the
 
[http://doc.sagemath.org/html/en/reference/structure/sage/structure/global_options.html
 GlobalOptions] class in `sage.structure.global_options` do not pickle,
 which is annoying and causes various problems. (This is a defect.)

 In addition, when the `GlobalOptions` class was introduced it was
 suggested in [https://groups.google.com/forum/#!searchin/sage-
 devel/globabloptions/sage-devel/7ApZgwBTU4U/Qe6QoeuYgvAJ sage-dev] that it
 "would be nice" if we could implement the syntax used in the IPython
 configuration:
 {{{

     A.options.foobar = 1

 in addition to

     A.options(foobar=1)
 }}}
 This ticket implements both of these features and, in addition, makes it
 possible to construct options classes dynamically.

 As was also suggested on sage-dev, I have also renamed all of the
 global_options methods simply as options, with the global_options variants
 being deprecated. The "stand-alone" options classes such as
 `PartitionOoptions`, `TableauxOptions`, ... have also been deprecated and,
 instead, put inside their "parent" classes where they are accessible using
 the `options` method (`global_options` methods have been deprecated). This
 is cleaned up the code a little and it seems to speed up the sage start-up
 time.

 The pickling is done by adding an extra `module` argument to the
 `GlobalOptions` that specifies the module which contains the class that
 the options are attached -- `name` of of the class defaults to the name of
 the options class but this can be explicitly set using the `options_class`
 argument. The options class is assumed to have an `options` method, and
 this is used to unpickle a pickle for an options class. `GlobalOptions`
 that do not arise as options methods for standard sage classes cannot be
 unpickled. The reason why the name of the module and class are passed, as
 strings, to `GlobalOptions` rather than the actual class is that this
 approach allows the options to be constructed during the initialisation of
 the (instance of the) class and, in turn, this allows the class to
 dynamically construct their options classes.

--

Comment (by andrew.mathas):

 Thanks Travis. Fixed. I have also cleaned up the deprecation messages,
 putting them in the same place, so that they will be easier to remove in
 future.

 Finally, should the `reset` method be `_reset()` or `Reset()`? Currently
 it is `_reset()` but it probably shouldn't be hidden.

--
Ticket URL: <https://trac.sagemath.org/ticket/18555#comment:17>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to