Hi Nils,

On 24 Sep., 21:04, Nils Bruin <nbr...@sfu.ca> wrote:
> Very interesting! Look at the big caveat, though: "marshal's format
> (any python bytecode for that matter) may not be compatable between
> major python versions."

Yes, that's not good. Unless it is possible to keep an old marshal
version around even after upgrading python?

> It would probably be good to see how
> much things break. e.g, what happens to introspection data when the
> object is unpickled on an installation where the source of the
> function is in a different location or not present?

If the source is present then the usual way of pickling-by-module-and-
name is available:

  sage: type(PolynomialRing)
  <type 'function'>
  sage: loads(dumps(PolynomialRing))
  <function PolynomialRing at 0x16d8d70>
  sage: dumps(PolynomialRing, compress=False)
  '\x80\x02csage.rings.polynomial.polynomial_ring_constructor
\nPolynomialRing\nq\x01.'

Hence, when pickling, this method will continue to be used - and if
you move the source file after pickling then of course things will
break at unpickling.

But in fact I was only talking about one case that has not been
covered by pickling yet: Interactive code. The idea is that one can
not only define stuff interactively (which, at least for me, is the
first step before writing a source file) but save what one wrote. I
think the possibility to later use a function that one has written in
an interactive session may be useful.

> Once you have this, people will be expecting to be able to pickle
> cython code as well ... [which could sort-of work if introspection is
> able to locate the source files ...]

The (temporary) source files can be located, with a couple of
introspection patches I wrote recently. I think they have already been
reviewed.

In the case of an interactive Cython function, pickling works, because
there is a source file, but unpickling in another session fails
because the source file is only temporary.
However, while I use interactive Python code frequently, my use of
interactive Cython code is less frequent. If it is the same for other
people, pickling interactive Cython code may be useless?

Best regards,
Simon

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to