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/2006-January/060134.html below:

[Python-Dev] Path inherits from string

[Python-Dev] Path inherits from stringM.-A. Lemburg mal at egenix.com
Thu Jan 26 21:48:16 CET 2006
Martin v. Löwis wrote:
> M.-A. Lemburg wrote:
>> Please note that inheritance from string will cause the C type
>> checks of the form PyString_Check(obj) to return true.
>> C code will then assume that it has an object which is
>> compatible to string C API which instances aren't.
> 
> Oh, sure they are. Types inheriting from str have the same
> layout as str, and C code assuming that layout will work fine
> with them. Inheritance works (saying "inheritance *just* works
> would deny the many fine details that have been engineered to
> actually make it work").

You're right, I forgot about how the .__new__() works on
new-style classes and that extra space is allocated
appended to the base type object for the extra
instance features.

>From PEP 253:
"""
    class C(B): pass

...

    In any case, the work for creating C is done by M's tp_new() slot.
    It allocates space for an "extended" type structure, containing:
    the type object; the auxiliary structures (as_sequence etc.); the
    string object containing the type name (to ensure that this object
    isn't deallocated while the type object is still referencing it);and
    some auxiliary storage (to be described later).  It initializes this
    storage to zeros except for a few crucial slots (for example,tp_name
    is set to point to the type name) and then sets the tp_base slot to
    point to B.

"""

Sorry for the FUD,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 26 2006)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
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