473,772 Members | 3,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Idle bytecode query on apparently unreachable returns

>What puzzles me, though, are bytecodes 17, 39 and 42 - surely these aren't
reachable? Does the compiler just throw in a default 'return None'
epilogue, with routes there from every code path, even when it's not
needed? If so, why?


Hi.

pyc (http://freshmeat.net/projects/pyc) can already remove that
unused code since June.

As for "why", I guess that there is a lot of room for optimizing
the bytecode but it's a PITA doing all of it in the current internal
compiler. And so developers simply don't care about it.
Maybe the ast-branch would make it easier to start generating
optimal bytecode. On the other hand, the 'compiler module'
produces bad bytecode (for example it miscalculates the 'stacksize'
of functions and as a result the generated functions are slow), it
doesn't use LIST_APPEND, and it doesn't even do the simple peephole
optimizations of the intenal compiler!
In the latest version 0.8 to-be-released, pyc does many more bytecode
optimizations that give a +5% to pystone and it can also bring
generator expressions and decorators to python 2.3.

[OT]
0.8 is stuck on the conditional. We can bring the conditional expression
from the __future__ to users of 2.3/2.4 but I'm not sure people really
like the "T if C else F" syntax over "C ? T : F".

The argument: "python uses 'and'/'or' instead of &&/|| and therefore
it should also use 'if-else' instead of '?:'", just doesn't apply.
And generally this is one of those things that you will never find
the argument that proves which is the right choice. In these cases
you do what you *LIKE* more.

Perhaps a vote would be in order considering the this-or-that
nature of the conditional expression :)
st.

----------------------------------------------------------------
This message was sent through the TEI of ATHENS by means of NOC.
Oct 11 '05 #1
0 1203

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

Similar topics

4
1643
by: Tom Anderson | last post by:
Evening all, Here's a brief chat with the interpretator: Python 2.4.1 (#2, Mar 31 2005, 00:05:10) on darwin Type "help", "copyright", "credits" or "license" for more information. >>> def fib(x): .... if (x == 1): .... return 1
3
6510
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the criteria, the Mid function returns the values when I run the query. So if one of the values is a "t" (no quotes), can I not ask to isolate that record by putting "t" as a criteria? Nope - error, error. If I put it within the expression itself...
6
11850
by: lakshmi | last post by:
Hi all I'm trying to traverse through the results from a query that returns more than 1 row. The data reader reads only the first row. The following code doesn't work. Let me know what's wrong. do { while(reader.read) { x += y;
19
46685
by: Frank Rizzo | last post by:
I want to log the user out when there has been a period of inactivity in the application. The key here is inactivity of the application, not the system. I know that you can retrieve the inactivity of the system via GetLastInputInfo. That's not what I want - I want inactivity of the application. Thanks.
5
2140
by: Kevin Buchan | last post by:
How can I tell if the system is 'idle', or the screen saver is running, or the machine is locked? I am writing an application that could really benefit from knowing this information. During 'idle' time, I could do some of the slightly heavier processing; during the 'working' time, I would display the non-intrusive notifications that I don't want my customer to miss. I see that I can apparently set the thread priority of my background...
18
3391
by: bobueland | last post by:
IDLE doesn't seem to honor PYTHONSTARTUP environment variable nor sitecustomize.py How do you then customize in IDLE? (basically I want to execute the statement from btools import * each time I restart IDLEs Python Shell)
8
1934
by: Vince Morgan | last post by:
Hi, I'm not sure that I have the right group, so please bear with me. Recently I created a fuction in the MS Access VBA IDE. The function returns a Boolean. I created the function to use as criteria in an Access query, and then I discovered a problem. The query runs ok, but it's apparently ignoring the functions return val. It doesn't matter whether the function returns true, or false. If I remember correctly (I haven't worked on it...
33
7459
by: ram.ragu | last post by:
hi i have problem to calculate idle time of cpu and if idle time is more then i have to shut down the system. can anyone tell me the idea to so that please
6
2100
by: Andreas Tawn | last post by:
I'm trying to integrate the timeout function from here http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473878 into a long running automation script and the following code causes IDLE after 20 or 30 iterations in countTest. This is in 2.5, XP and there's no traceback. Could someone point me at the user error? Thanks in advance.
1
2513
by: HillBilly | last post by:
What does that error mean and why would each break statement be marked as unreachable? It implies the return will --always-- return some --thing-- if even null and no further processing can possibly be done after the return statement hence the break statement will not and can ever be reached? switch (suffix) { case 1: return "<sup>st</sup>"; break;
0
9454
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,...
0
10104
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9912
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6715
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();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3
2850
bsmnconsultancy
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...

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.