A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-October/083216.html below:

[Python-Dev] Proper initialization of structs

[Python-Dev] Proper initialization of structsAlexandre Vassalotti alexandre at peadrop.com
Fri Oct 31 01:10:38 CET 2008
[oops, I forgot to cc the list]

On Thu, Oct 30, 2008 at 7:43 PM, Christian Heimes <lists at cheimes.de> wrote:
> Alexandre Vassalotti wrote:
>>
>> And that is exactly the reason why, the _pickle module doesn't use
>> __new__ for initialization.  Doing any kind of argument parsing in
>> __new__ prevents subclasses from customizing the arguments for their
>> __init__.
>>
>> Although, I agree that __new__ should be used, whenever it is
>> possible, to initialize struct members.
>
> You are missunderstanding me. I want everybody to set the struct members to
> *A* sensible default value, not *THE* value. Argument parsing can still
> happen in tp_init. tp_new should (or must?) set all struct members to
> sensible defaults like NULL for pointers, -1 or 0 for numbers etc.
>
> Python uses malloc to allocate memory. Unless you are using debug builds the
> memory block is not initialized. In both cases the block of memory isn't
> zeroed. You all know the problems caused by uninitialized memory.
>

But what if  PyType_GenericAlloc is used for tp_alloc? As far as I
know, the memory block allocated with PyType_GenericAlloc is zeroed.

-- Alexandre
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4