473,569 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

campaining for PEP 238 - integer division

Hi,
I'm interested in having more people in our lab using numarray/NumPy
instead of MatLab. For that I have put together a couple useful
modules and written many myself. But then I got reminded of a new /
upcoming feature of Python:
"2/3 == 1.5" AKA PEP 238.
I'm very interested in putting lots of
"from __future__ import division"
lines into my code especially since numarray (the new NumPy) now
supports it.

QUESTION: Is this new/upcoming feature of Python mentioned enough ?
Like in the Python tutorial or mailing lists ...
A google groups search for "python 238 integer OR division" was
giving me one relevant result from Jan2004, another one from May2003,
all else even older !!!

I think people need to be reminded that PEP238 is really happening
and especially new people should be pointed to this --
The fact is that changing something as fundamental as the division
operator WILL BRAKE LOTS OF CODE !! I'm just thinking of all the
'a[n/2]' expressions I have in my code.

PROPOSAL: This is why I would like to see some special treatment for
PEP 238. If the division operator is going to change this should be
noted right in the first chapter of the Python tutorial (Python as
calculator). Remind all python developers that they will have to
change their code. (Actually: is there an easy 'fix' like "from
__past__ import division" ?)

Cheers,
Sebastian Haase
Jul 18 '05 #1
2 1904
"Sebastian Haase" <se*******@yaho o.com> wrote in message
news:f4******** *************** ***@posting.goo gle.com...
Hi,
I'm interested in having more people in our lab using numarray/NumPy
instead of MatLab. For that I have put together a couple useful
modules and written many myself. But then I got reminded of a new /
upcoming feature of Python:
"2/3 == 1.5" AKA PEP 238.
I'm very interested in putting lots of
"from __future__ import division"
lines into my code especially since numarray (the new NumPy) now
supports it.

QUESTION: Is this new/upcoming feature of Python mentioned enough ?
Like in the Python tutorial or mailing lists ...
A google groups search for "python 238 integer OR division" was
giving me one relevant result from Jan2004, another one from May2003,
all else even older !!!
According to the current version of the PEP, that change won't
happen until sometime in the misty future with version 3.0. That
release is scheduled to break lots of things, not just this one.

The PEP contains recommendations for cushioning the shock.

John Roth

Cheers,
Sebastian Haase

Jul 18 '05 #2
Sebastian Haase wrote:
The fact is that changing something as fundamental as the division
operator WILL BRAKE LOTS OF CODE !!

^^^^^

Ah, so *that's* why my code isn't running fast enough...

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg

Jul 18 '05 #3

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

Similar topics

19
5142
by: Imbaud Pierre | last post by:
integer division and modulo gives different results in c and python, when negative numbers are involved. take gdb as a widely available c interpreter print -2 /3 0 for c, -1 for python. more amazing, modulos of negative number give negative values! (in c). from an algebraic point of view, python seems right, but I thought python conformity...
15
51007
by: joel | last post by:
I have a table which I want to update by dividing one field into another. The update runs with no errors, but the results come out as only a positive integer number. The datatype for the result field is float. The datatype for the other fields are int. I have tried testing by dividing 7 by 10000, which should give me 0.0007. The result...
24
19309
by: Teis Draiby | last post by:
In .NET, can I be sure that the result of a division between two integers always is truncated rather that rounded to nearest? Example: 99 / 50 = 1 regards, Teis
17
2398
by: seb.haase | last post by:
Hi, Is it true that that "Python 3000" is dead ? Honestly I think that e.g. changing 5/2 to be 2.5 (instead of 2) would just break to much code :-( On the otherhand I'm using Python as "Matlab replacement" and would generally like 5/2 ==2.5 So, I was contemplating to default all my modules/scripts to start with "from __future__ import...
10
3167
by: Mike S | last post by:
Does anyone know the logic behind why in VB.NET the result of a floating-point division ('/') is -rounded- on being converted to an integer type, such as with statements like Dim x As Integer = 2/3 'after assignment, x is 1, whereas a sane person would say it should be 0 Does Microsoft have a reason for this design decision? I understand...
9
43535
by: PengYu.UT | last post by:
Hi, The usually integer division will round the result to the biggest integet smaller than the float version division.For example, 10/3 = 3. I'm wondering if there is any easy way to round it to 4 for this case? Thanks, Peng
2
3855
by: kermit | last post by:
For a long time,, There has been a discussion of trueFor division versus integer division in Python. I myslef prefer that / be used for integer division since almost always, I want the result of the division be truncated to integer. However, today I reviewed the method to be used in Python to get true division, and this gave
13
7101
by: jamesonang | last post by:
Supposed unsigned int(32 bits) is the largest number that computer can represent with a single variable. Now, i have a big integer ( less than 64 bit, but great than 32 bit) . i represent it by this way: unsigned int dividend : divident store low 32 bits of big integer, dividend store high 32 bits of big integer.
16
5257
by: spl | last post by:
To increase the performance, how to change the / operator with bitwise operators? for ex: 25/5, 225/25 or 25/3 or any division, but I am not bothered of any remainder.
0
7701
marktang
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...
0
7615
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...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
jinu1996
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...
1
7677
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...
0
7979
tracyyun
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...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
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...
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.