I was perhaps not clear enough in my first question. Below ...

On 30/09/2013 00:15, fwierzbicki@gmail.com wrote:
On Sat, Sep 28, 2013 at 4:18 PM, Jeff Allen <ja.py@farowl.co.uk> wrote:
...
I would like to check that these things are not bad ideas before I write
too much:

1. I will change the signature of about a dozen of the exposed methods
to take a PyObject argument where they currently take Java String. (They
are package-visible, so I should find any call sites easily.)
Is it possible to overload the functions so that we still take
java.lang.String? I think it would be too bad if we had to lose the
ability to call the methods that take java.lang.String. For example,
if we are calling from Java we might have a java.lang.String and it
would be inconvenient to be forced to wrap it in a PyObject first.

I mean that, for example, we have:

    public int find(String sub) {
        return str_find(sub, null, null);
    }

    public int find(String sub, PyObject start) {
        return str_find(sub, start, null);
    }

    public int find(String sub, PyObject start, PyObject end) {
        return str_find(sub, start, end);
    }

    @ExposedMethod(defaults = {"null", "null"}, doc = BuiltinDocs.str_find_doc)
    final int str_find(String sub, PyObject start, PyObject end) {
        ...
    }

In the last, I will change the signature to:
    final int str_find(PyObject sub, PyObject start, PyObject end)

The method itself then has to take care of the actual type instead of the calling mechanism doing the coercion. It may be a problem if anyone is calling it directly, but as it is package-visible, either that's within our codebase or they knew they were taking a risk.

I haven't considered fully the public API, which I think is what you are talking about. Overloading methods would work but we'd have 6 methods where we have 3 already, just for find(), with the addition of:
    public int find(PyObject sub)
    public int find(PyObject sub, PyObject start)
    public int find(PyObject sub, PyObject start, PyObject end)

Or maybe:
    public int find(BufferProtocol sub)
    ...

It just seems a lot of methods, like I was missing The Better Way.

Jeff