473,327 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

API functions not working as expected

.... for reasons that are obvious in retrospect. Specifically, I am
talking about the PyNumber_InPlace* family of functions. For example,
the docs for InPlaceAdd say:

PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2)
Return value: New reference.
Returns the result of adding o1 and o2, or NULL on failure. The
operation is done in-place when o1 supports it. This is the equivalent
of the Python statement "o1 += o2".

But, of course, numbers are immutable. None of them support in-place
addition. This is not the same as o1 += o2, as o1 is not actually
changed when using this function.

Am I missing something here? Is there, in fact, no point to these
InPlace* functions?

-Kirk McDonald
Jun 15 '06 #1
1 1191
On 16/06/2006 9:51 AM, Kirk McDonald wrote:
... for reasons that are obvious in retrospect. Specifically, I am
talking about the PyNumber_InPlace* family of functions. For example,
the docs for InPlaceAdd say:

PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2)
Return value: New reference.
Returns the result of adding o1 and o2, or NULL on failure. The
operation is done in-place when o1 supports it. This is the equivalent
of the Python statement "o1 += o2".

But, of course, numbers are immutable. None of them support in-place
addition. This is not the same as o1 += o2, as o1 is not actually
changed when using this function.

Am I missing something here? Is there, in fact, no point to these
InPlace* functions?


Well, I guess it all depends on your expectations ...

I've never used any of those functions, but after a quick perusal of the
manual, here's my expectation:

Looking at the heading of the manual section ("Number protocol"), I take
that to mean that the contents relate to operations on objects which
support some of the (mostly) binary operators usually associated with
numbers.

I expect that PyNumber_Add will work with numbers, strings, lists, and more.

I expect that PyNumber_InPlaceAdd will work like PyNumber_Add for
numbers and strings, and do o1.extend(o2) for lists.

I expect a similar story with PyNumber_(InPlace)?Or and sets.

By the way, I also have an expectation that the core devs don't waste
their time and talents writing, testing and documenting pointless
functions. Any suspicions that I may have had to the contrary over the
time since I was first pointed at Python 1.5.1 have proved to be wrong
and founded on my own ignorance.

HTH,
John
Jun 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and...
2
by: Wenjie | last post by:
Hello, I read someone posted assertions that even the (public) member function is not static, there are probably only one copy of the code in the executable. Then except the...
25
by: Stijn Oude Brunink | last post by:
Hello, I have the following trade off to make: A base class with 2 virtual functions would be realy helpfull for the problem I'm working on. Still though the functions that my program will use...
4
by: Jim S | last post by:
A number of functions that I use regularly in Access, either in queries or reports, have stopped working within the last couple of days. They include: Left() InStr() Now() When run in a...
0
by: Sarah J | last post by:
Hi We have a high traffic PHP built website which, for reasons beyond my control, is hosted on a twin processor (Zeus) Windows 2003/IIS6 server. PHP 4.4.1 came preinstalled as a CGI but because...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
15
by: Jaraba | last post by:
I am working in a project that I need to parse an arrayt an select records based upon the values parsed. I used the functions developed by Knut Stolze in his article 'Parsing Strings'. I am...
25
by: OziRus | last post by:
Hi, This is my first message on this group. I want to ask something about screen-drawing functions. I wrote and compiled below code succesfully on TC IDE in Win-xp. Then i tried to work it on...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.