simon-git: spigot (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sat Oct 21 10:55:29 BST 2017


TL;DR:
  3e59e04 Python turn Spigot.from_foo() into proper class methods.
  c30b01b Python: make spigot.fraction() default denominator to 1.
  620f490 Python: make spigot.eval() and .fraction() class methods.
  9ca7b28 Python: rename Spigot.{floor,ceil,toint,sign}.
  8ce1d7f Rewrite 'testenv' Python script to support --build-base.
  ab71d88 Reorganise to bring setup.py to the top level.
  7d1ccde Tidy up .gitignore.

Repository:     https://git.tartarus.org/simon/spigot.git
On the web:     https://git.tartarus.org/?p=simon/spigot.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2017-10-21 10:55:29

commit 3e59e0478472c3092e77eb5274962ede9a62026b
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=3e59e0478472c3092e77eb5274962ede9a62026b;hp=8cb1657f255d9d579f9e9d9784b46072f37ec5b5
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Oct 21 07:15:06 2017 +0100

    Python turn Spigot.from_foo() into proper class methods.
    
    I now realise that if they're going to be defined using 'classmethod'
    and take a parameter which is the class type, they should _use_ that
    parameter to construct their return type. That way, if anyone ever
    needs to subclass my Spigot class for any reason, then their
    SpigotSubclass.from_digits() and similar methods will automatically
    construct a SpigotSubclass instead of a plain Spigot.
    
    If I'm doing that, it's easier to define them as class methods first
    and _export_ to the module's top level, rather than vice versa.

 python/spig/__init__.py | 76 ++++++++++++++++++++++++++-----------------------
 1 file changed, 40 insertions(+), 36 deletions(-)

commit c30b01b1c58c4c8429581aad993a67fff1b3498b
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=c30b01b1c58c4c8429581aad993a67fff1b3498b;hp=3e59e0478472c3092e77eb5274962ede9a62026b
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Oct 21 07:26:50 2017 +0100

    Python: make spigot.fraction() default denominator to 1.
    
    This makes spigot.fraction() behave more like the constructor for
    fractions.Fraction, which seems like a useful thing to keep
    consistent.
    
    In particular, this makes it possible to use spigot.fraction as the
    argument to Spigot.to_convergents(), to get a stream of convergents in
    the form _of Spigot objects_. That certainly seems like a thing you
    want to make possible - surely exporting things out of the Spigot
    world can't be the _only_ use for to_convergents.
    
    (As it happens, you could actually have done that anyway by using the
    class Spigot _itself_ as the argument. But using spigot.fraction seems
    like almost a more natural way of phrasing the same concept, so I'd
    like to ensure it does work.)

 python/spig/__init__.py | 2 +-
 python/testsuite.py     | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

commit 620f490b50378650f910517d29dd2a42c513b1d3
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=620f490b50378650f910517d29dd2a42c513b1d3;hp=c30b01b1c58c4c8429581aad993a67fff1b3498b
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Oct 21 07:29:29 2017 +0100

    Python: make spigot.eval() and .fraction() class methods.
    
    This way they share the same (new) useful property of the from_foo
    methods, that if called on a subclass they'll construct an instance of
    that subclass to return.
    
    As with the other class-method constructors, they're exported back to
    the top level, so this doesn't change any previously existing part of
    the API.
    
    But since most of the other methods on the Spigot class itself, like
    the overloaded operators, are all implemented in terms of eval, this
    means that _those_ all switch to calling the eval method of their own
    class, so this also gets us for free the property that arithmetic on a
    Spigot subclass will propagate the same subclass type rather than
    reverting annoyingly to the base Spigot class.

 python/spig/__init__.py | 57 ++++++++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 27 deletions(-)

commit 9ca7b280b3e1acadb0776ee33104e8434ce46314
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=9ca7b280b3e1acadb0776ee33104e8434ce46314;hp=620f490b50378650f910517d29dd2a42c513b1d3
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Oct 21 07:49:50 2017 +0100

    Python: rename Spigot.{floor,ceil,toint,sign}.
    
    Now to_int is named in a way that better matches the other to_foo
    methods, and floor_int, ceil_int and sign_int are named to reflect
    their return type.
    
    This also means I can export that whole family into top-level unary
    functions without colliding with the existing floor, ceil and sign
    functions exported from the spigot core (which return type Spigot
    rather than int).

 python/demo.py          |  2 +-
 python/spig/__init__.py | 21 +++++++++++++--------
 python/testsuite.py     | 26 +++++++++++++++++---------
 3 files changed, 31 insertions(+), 18 deletions(-)

commit 8ce1d7f1a5e77070aad8cc123e9ef3a86b0f08c0
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=8ce1d7f1a5e77070aad8cc123e9ef3a86b0f08c0;hp=9ca7b280b3e1acadb0776ee33104e8434ce46314
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Oct 21 10:40:25 2017 +0100

    Rewrite 'testenv' Python script to support --build-base.
    
    This gives it the ability to look in a build directory that isn't
    found by looking alongside the script itself, which will come in handy
    in the directory and build script reorganisation I'm about to do.
    
    As a side effect of supporting that one command-line option, I've also
    rewritten the whole script in the form of something halfway organised
    into logically separate subfunctions with my usual style of argparse-
    based main() on the front. The previous version looked like a
    three-line script overgrown to 30 lines; this one looks as if it might
    have had a _little_ planning involved at some point.

 python/testenv | 92 +++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 62 insertions(+), 30 deletions(-)

commit ab71d8898ca6610ca7ce6ff717e468923dcbb2de
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=ab71d8898ca6610ca7ce6ff717e468923dcbb2de;hp=8ce1d7f1a5e77070aad8cc123e9ef3a86b0f08c0
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Oct 21 10:44:38 2017 +0100

    Reorganise to bring setup.py to the top level.
    
    With setup.py one level down in the 'python' subdirectory, the
    'setup.py sdist' subcommand to build a source distribution didn't
    work, because it would produce a tarball that omitted all the C++
    source files from the parent directory. I _could_ have hacked around
    that in a really horrible way, but it seemed nicer to just bring the
    script up to the top level.
    
    While I'm about it, I've reorganised a bit so that the Python module
    itself (both the __init__.py Python-side half and the C++ Python
    integration code) now lives in a subdir 'python-module', and the demo
    programs live in 'python-demos'. With the latter change, I can also
    remove the annoying .py from the end of all their names.
    
    I've removed the old python/README that said "don't use this because I
    might change the API". I think I've now finished redesigning pieces of
    API (though I may yet _add_ a few things), and am declaring the API
    stable enough that people can start using it if they want to.
    
    The top-level Buildscr builds and tests the Python module's source
    tarball, but does not include it among the output build products. I'll
    leave that until I've written the documentation for the module; until
    then, it may have a stable API but it's not yet of shipping quality.

 .gitignore                 |   4 +-
 Buildscr                   |  17 +-
 python-demos/demo          | 163 ++++++++
 python-demos/mediant       | 187 ++++++++++
 python-demos/powbegin      | 626 +++++++++++++++++++++++++++++++
 python-demos/pythangle     | 141 +++++++
 python-module/__init__.py  | 479 ++++++++++++++++++++++++
 python-module/internal.cpp | 900 +++++++++++++++++++++++++++++++++++++++++++++
 python-module/testenv      |  75 ++++
 python-module/testsuite    | 846 ++++++++++++++++++++++++++++++++++++++++++
 python/README.txt          |  36 --
 python/demo.py             | 163 --------
 python/mediant.py          | 187 ----------
 python/powbegin.py         | 626 -------------------------------
 python/pyspig.cpp          | 900 ---------------------------------------------
 python/pythangle.py        | 141 -------
 python/setup.py            |  70 ----
 python/spig/__init__.py    | 479 ------------------------
 python/testenv             |  75 ----
 python/testsuite.py        | 845 ------------------------------------------
 setup.py                   |  56 +++
 21 files changed, 3489 insertions(+), 3527 deletions(-)

commit 7d1ccdedbed48eece83cac4f27fb317877b8aded
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=7d1ccdedbed48eece83cac4f27fb317877b8aded;hp=ab71d8898ca6610ca7ce6ff717e468923dcbb2de
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Oct 21 10:50:05 2017 +0100

    Tidy up .gitignore.
    
    A lot of the things it ignored should have had a leading / to indicate
    that they're only expected to appear at the top level.
    
    Also, removed the ignore line for 'notes'; leaving files called that
    lying around is a naming habit I don't even use myself any more, and
    even when I did, I should have been putting ignore rules for my
    personal habits in .git/info/exclude where they would stay personal to
    my own checkouts.

 .gitignore | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)



More information about the tartarus-commits mailing list