472,978 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Is LOAD_GLOBAL really that slow?

It seems a common opinion that global access is much slower than local
variable access. However, my benchmarks show a relatively small
difference:

../python -m timeit -r 10 -v -s 'x = [None] * 10000
def foo():
for i in x:
list; list; list; list; list; list; list; list; list; list' 'foo()'
10 loops -0.0989 secs100 loops -0.991 secs
raw times: 0.999 0.985 0.987 0.985 0.985 0.982 0.982 0.982 0.981 0.985
100 loops, best of 10: 9.81 msec per loop

../python -m timeit -r 10 -v -s 'x = [None] * 10000
def foo():
mylist = list
for i in x:
mylist; mylist; mylist; mylist; mylist; mylist; mylist; mylist;
mylist; mylist' 'foo()'
10 loops -0.0617 secs
100 loops -0.61 secs
raw times: 0.603 0.582 0.582 0.583 0.581 0.583 0.58 0.583 0.584 0.582
100 loops, best of 10: 5.8 msec per loop

So global access is about 70% slower than local variable access. To
put that in perspective, two local variable accesses will take longer
than a single global variable access.

This is a very extreme benchmark though. In practice, other overheads
will probably drop the difference to a few percent at most. Not that
important in my book.

So my question: does somebody have a globals benchmark that shows a
really significant slowdown vs local variables?

--
Adam Olsen, aka Rhamphoryncus
Aug 30 '07 #1
0 842

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

Similar topics

6
by: Zip Code | last post by:
"The large print giveth, and the small print taketh away.", so said Tom Waites in his classic rap, "Step Right Up", a paean about come ons and rip offs. Now, we have all explored the fact that...
9
by: vincent wang | last post by:
Microsoft has been pushing very hard behind .Net, but why haven't we seen any real action or plan that Microsoft is going to port its own software, especially Office onto .Net? If they don't want...
5
by: Rob R. Ainscough | last post by:
This is more of a conceptual question: 1. More and more companies are using VPN's and locking out internet connectivity (for a host of reasons, security, productivity, etc.). 2. ASP.NET...
2
by: Gary Wright | last post by:
I have a split db with the back end on a server and the front end on several client machines. There is supposedly a 100MB ethernet between the two that is generally quite lightly loaded. The...
7
by: ddsvi78 | last post by:
I am a complete idiot when it comes to access. Now that said, I work for a computer security company and one of our customers came to us with an access problem. They had been running fine for a...
1
by: z. f. | last post by:
Hi, i have a dot-net app. the first load is really slow, about 4 seconds at least. next requests are very fast. is there a way to analyze the buttleneck in the load process of a asp-net...
7
by: Fredrik Melin | last post by:
Running a solution with about 20 sub-projects total about 150.000 lines of code. Typing code is slow (delay when typing fast). Pressing next line while debugging is slow. Pressing Ctrl-F for...
3
by: michael | last post by:
Hi, I am trying to write an ASP.NET web app, in Visual Basic.NET, using Visual Studio.NET 2004, .NET framework 1.1.4322 SP1 Running the project/app on localhost while in dev/write/debug stage ...
0
by: CptDondo | last post by:
I have a website that is generated on the fly from XML templates. I've been having some performance issues (pages taking 6 seconds or more to be generated) and profiled the php code. (This is an...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.