473,394 Members | 1,739 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,394 software developers and data experts.

Re: Question about optimization

On Thu, 24 Jul 2008 17:19:41 -0400, Wei Hao <we******@gmail.comwrote:
>Hi:

I'm pretty new to python and I have some optimization issues. I'll show you
the piece of code which is causing it, with pseudo-code before it and
comments. I'm accessing a gigantic table (like 15 million rows) in SQL.

d is some dictionary, r is a precompiled regex string
Big loop, so I search through the table in chunks given by delta
SQL query ("select * from table where rowID >= n and rowID < (n +
delta)"), result of query stored in a. Each individual row is a[n1], columns
of rows are a[n1][n2].

[snip]

I am 100% sure it's this code snippet that's the cause of my problems.
Here's what I can tell you. Each chunk of rows that I grab is essentially
equal in size (rowID skips over stuff, but rather arbitrarily). The time it
takes to fetch the SQL query doesn't change. But as the program progresses,
this snippet gets slower. Here's the output:

2500 0.441551299341
5000 1.26162739664
7500 2.35092688403
10000 3.48417469666
12500 4.59031305491
15000 5.78972588775
17500 6.28305527139
20000 6.73344570903
22500 8.31732146487
25000 9.65322872159
27500 8.98186042757
30000 11.8042818095
32500 12.1965593712
35000 13.2735763291
37500 14.0282617344

What is it in the code snippet that slows down as n increases? Is there
something about the way low level python functions I don't understand which
is slowing me down?
Perhaps you need an index on rowID.

Jean-Paul
Jul 24 '08 #1
0 652

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

Similar topics

111
by: JKop | last post by:
Okay here we go, I feel it's about time people conversed about the bullshit aspects of C++ (including the bullshit stuff brought forward from C). I'll begin with a few of my own grievances: 1)...
2
by: gurpreet | last post by:
Hi this is gurpreet, I know this is a very simple question but still I want to clear some doubts. What happens when we compile and link a c-program? I hope aquite a lot of responses to my...
15
by: Marc Thrun | last post by:
Hello, I've got a few questions: 1) Given the two structs struct A { int x; }; and
68
by: James Dow Allen | last post by:
The gcc compiler treats malloc() specially! I have no particular question, but it might be fun to hear from anyone who knows about gcc's special behavior. Some may find this post interesting;...
18
by: gutmant | last post by:
Say you have a file, a.h with an include guard. If you include it twice and look at the preprocessed output, you see there's no sign for the second inclusion. However, if you include it twice -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
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...
0
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...

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.