[Python-Dev] Usability of the limited API

Steve Dower Steve.Dower at microsoft.com
Thu May 28 17:02:36 CEST 2015

Paul Moore wrote:
> On 28 May 2015 at 15:28, Steve Dower <Steve.Dower at microsoft.com> wrote:
>> I don't have the issue number handy, but it should be near the top of
>> the recently modified list.
> I recall seeing that issue. I'm fine with that - getting the two in sync is
> obviously worth doing (and clearly in hand). I'm personally not sure whether
> automating the exposure of symbols is the correct approach, as I'm not sure
> people typically even consider the stable API when adding functions. Is the
> default (what you get if somebody just blindly adds a symbol with no thought for
> the stable API) to expose it or not? If the default is that it's not exposed,
> then automation seems reasonable, otherwise I'm not so sure.

Now I'm at my desk, the issue is http://bugs.python.org/issue23903

I believe new symbols are considered stable by default, so perhaps we actually want a test that will generate a C file that imports everything "stable" and will break the buildbots if someone adds something new without explicitly adding it to the list of stable functions? That sounds like the only way to make the extra overhead of two lists work. I guess we could also invert all the logic in the header files so that symbols are unstable by default.

> The bigger issue for me is that it looks like the stable API doesn't include
> functions that allow you to just run a script/file.

I think a combination of Py_CompileString and PyEval_EvalCode is what you want here, though I can't think of any good reason not to have a stable helper method (or even a macro?) for this.

> At a minimum, PyRun_SimpleString should be available. I'd also like to see a
> variant of PyRun_SimpleFile that let you pass a filename (either a .py file, or
> a zipfile, or a directory name - basically what you can pass to the Python
> interpreter directly). You can sort of do it via "import runpy;
> runpy.run_path(filename)", but you get into all sorts of fun with requoting
> filenames, etc.
> With the fact that we're distributing an embeddable interpreter for Windows, I'd
> like to be able to promote it as a bundling option, easier to use than things
> like py2exe/cx_Freeze.

Agreed. This is the point of the zip file :)


> Paul

More information about the Python-Dev mailing list