Hi all,
Of what I heard Python 2.3 now allow creation of new types in C with
slots.
Is there somewhere some documentation on this, or at least an example ?
Thanks a lot
Boris 7 1807
Boris Boutillier wrote: Hi all,
Of what I heard Python 2.3 now allow creation of new types in C with slots. Is there somewhere some documentation on this, or at least an example ?
I'm not sure what you mean by "with slots" in this context. Creating
new types is well documented at: http://www.python.org/doc/current/api/newTypes.html
and descriptors, assuming that might be what you mean by 'slots',
at http://users.rcn.com/python/download/Descriptor.htm (all the
examples there are in Python, but it should be easy for you to
translate them into C).
Alex
Alex Martelli <al***@aleax.it > writes: Boris Boutillier wrote:
Hi all,
Of what I heard Python 2.3 now allow creation of new types in C with slots. Is there somewhere some documentation on this, or at least an example ?
I'm not sure what you mean by "with slots" in this context. Creating new types is well documented at:
http://www.python.org/doc/current/api/newTypes.html
and descriptors, assuming that might be what you mean by 'slots', at http://users.rcn.com/python/download/Descriptor.htm (all the examples there are in Python, but it should be easy for you to translate them into C).
I would guess he means this: http://www.python.org/sf/696193
and I would also be interested in an example.
Thomas
Thomas Heller wrote:
... Of what I heard Python 2.3 now allow creation of new types in C with slots.
... I would guess he means this:
http://www.python.org/sf/696193
i.e. METAtypes (types whose instances are types) with '__slots__' ...?
and I would also be interested in an example.
Sorry, I've never written a metatype in C -- always in Python, almost
invariably inheriting from the built-in type.
"Normal" C types don't _need_ __slots__ of course, since __slots__'s
effect (avoiding a per-instance dict) is most easily achieved by
simply leaving the tp_dictoffset field at 0 (as most built-in types
do, save for those who DO want a per-instance dict -- functions and
modules come to mind).
Alex
That was not clear.
By slots, I mean the equivalent of '__slots__' in pure python,
ie adding some attribute as offsets at the end of the C description of a
Type.
And in fact what I am really looking for is how to describe '__slots__' in the C
description of a Metaclass.
Hope this make it a bit clearer.
Boris
On Fri, 17 Oct 2003 14:58:44 +0000, Alex Martelli wrote: Boris Boutillier wrote:
Hi all,
Of what I heard Python 2.3 now allow creation of new types in C with slots. Is there somewhere some documentation on this, or at least an example ?
I'm not sure what you mean by "with slots" in this context. Creating new types is well documented at:
http://www.python.org/doc/current/api/newTypes.html
and descriptors, assuming that might be what you mean by 'slots', at http://users.rcn.com/python/download/Descriptor.htm (all the examples there are in Python, but it should be easy for you to translate them into C).
Alex
Thanks Thomas, I think this is exactly what I was looking for.
Boris
On Fri, 17 Oct 2003 17:20:49 +0200, Thomas Heller wrote: Alex Martelli <al***@aleax.it > writes:
Boris Boutillier wrote:
Hi all,
Of what I heard Python 2.3 now allow creation of new types in C with slots. Is there somewhere some documentation on this, or at least an example ?
I'm not sure what you mean by "with slots" in this context. Creating new types is well documented at:
http://www.python.org/doc/current/api/newTypes.html
and descriptors, assuming that might be what you mean by 'slots', at http://users.rcn.com/python/download/Descriptor.htm (all the examples there are in Python, but it should be easy for you to translate them into C).
I would guess he means this:
http://www.python.org/sf/696193
and I would also be interested in an example.
Thomas
"Boris Boutillier" <bo************ **@arteris.net> writes: That was not clear. By slots, I mean the equivalent of '__slots__' in pure python, ie adding some attribute as offsets at the end of the C description of a Type. And in fact what I am really looking for is how to describe '__slots__' in the C description of a Metaclass.
Either you or I are confused: do you want the slots to appear on the
*type* or on *instances of the type*?
Cheers,
mwh
--
In general, I'd recommend injecting LSD directly into your temples,
Syd-Barret-style, before mucking with Motif's resource framework.
The former has far lower odds of leading directly to terminal
insanity. -- Dan Martinez
[Thomas] I would guess he means this:
http://www.python.org/sf/696193
and I would also be interested in an example.
[Boris] Thanks Thomas, I think this is exactly what I was looking for.
For an alternative, which also works on Python 2.2, you can take a look
into the sources for ctypes.
Thomas This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jacek Generowicz |
last post by:
I am writing an extension type, and wish to add some magic methods
which are not catered for by the tp_<whatever> slots (eg tp_init ->
__init__) in PyTypeObject. My methods seem to work correctly when
invoked explicitly (eg obj.__iadd__(3)) but the method seems not to be
associated with the corresponding operator (ie obj += 3 does NOT
work).
What am I likely to be doing wrong ?
|
by: mscir |
last post by:
I'm trying to find thorough documentation for creating graphs using
serverside Excel from ASP. Any book recommendations?
A well-documented COM wrapper would be nice if it allowed us to create
may different types of graph, e.g. Wind Rose (for wind direction),
thermometer, as well as standard pie, line, bar charts. I've found a few
examples of charting code on websites and at MS, but none of them
contain a thorough explanation, and our...
|
by: ALI-R |
last post by:
Hi All,
First of all I think this is gonna be one of those threads :-) since I have
bunch of questions which make this very controversial:-0)
Ok,Let's see:
I was reading an article that When you pass a Value-Type to method call
,Boxing and Unboxing would happen,Consider the following snippet:
int a=1355;
myMethod(a);
......
|
by: Cameron Laird |
last post by:
QOTW: "Python makes it easy to implement algorithms." - casevh
"Most of the discussion of immutables here seems to be caused by
newcomers wanting to copy an idiom from another language which doesn't
have immutable variables. Their real problem is usually with binding,
not immutability." - Mike Meyer
Among the treasures available in The Wiki is the current
copy of "the Sorting min-howto":
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |