Author eric.snow
Recipients Decorater, eric.snow, ncoghlan, serhiy.storchaka, vstinner
Date 2017-11-21.21:06:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511298376.61.0.213398074469.issue32096@psf.upfronthosting.co.za>
In-reply-to
Content
> IMHO for the long term, the best would be to have a structure for
> pre-Py_Initialize configuration, maybe _PyCoreConfig, and pass it
> to functions that can be called before Py_Initialize().

+1

As an alternative to that, we could also deprecate using any of those functions before initializing the runtime.   Instead of calling them, you would set the relevant info on the runtime "config" struct that you pass to the replacement for PyInitialize().  At that point we would not need some of those functions any longer and we could remove them (eventually, once backward-compatibility is resolved).  Given that the community of CPython embedders is relatively small, we're still in a position to iron this out

Regardless, I see where you're coming from.  I'm okay with reverting the Object/obmalloc.c parts, but, like I said, I'd rather avoid it if possible.

Solution #2 (that I listed above), AKA PR #4481, is focused and effective.  Unfortunately, it feels like a bit like a hack to me, though it is a well-contained hack.  So I'm not convinced it's the best solution.  However, I like it as much as I like reverting the allocators.

Solution #3, AKA PR #4495, is nice and clean, but potentially adds a little overhead to all PyMem_RawMalloc() and PyMem_RawFree() calls.  All the other PyMem_* functions are unaffected, so perhaps the overall impact is not significant enough to worry.


>> 2. statically initialize the "raw" allocator with defaults, enough
>>   to make PyMem_RawMalloc() and PyMem_RawFree() work pre-init (this
>>   is what my PR does)
>
> As I explained, the code to initialize PyMem_Raw allocator is complex
> and I would really prefer to only initialize it "partially" to prevent
> bad surprises.

The surprises would only be pre-initialization, right?  After the runtime is initialized, the allocators are in the proper fully-initialized state.  So it mostly boils down to what parts of the C-API embedders can use before initialization and how those functions interact with the raw memory allocator.  Those constraints narrow down the scope of potential problems to a manageable size (I won't say small, but it feels that way).

Ultimately, I favor solution #3 if we can see that it does not impact performance.  If we can't come to an agreement in a timely fashion then I'll go along with #1 (revert), so that we don't leave the embedding story broken.  If we go that route, do you think we could resolve the initialization issues within the 3.7 timeframe?
History
Date User Action Args
2017-11-21 21:06:16eric.snowsetrecipients: + eric.snow, ncoghlan, vstinner, serhiy.storchaka, Decorater
2017-11-21 21:06:16eric.snowsetmessageid: <1511298376.61.0.213398074469.issue32096@psf.upfronthosting.co.za>
2017-11-21 21:06:16eric.snowlinkissue32096 messages
2017-11-21 21:06:16eric.snowcreate