Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-22 Thread Vishal
Yeah I agree with you Noufal, that it is low level language thinking.
However, when we decided to go to Python, it was because its development
speed was wonderful.
After having everything in Python now, performance is something people want
to look at. Hence these efforts.

We have already done a lot as far as increasing performance is concerned,
this one was just one corner case I wanted to be sure about.

Thanks for all the replies.

Vishal Sapre

On Tue, Dec 22, 2009 at 9:12 PM, Noufal Ibrahim  wrote:

> On Tue, Dec 22, 2009 at 7:10 PM, Vishal  wrote:
>
> > Hi,
> >
> > I was presuming that since tuples are immutable, like strings, and string
> > immutability increases performance (
> > http://effbot.org/pyfaq/why-are-python-strings-immutable.htm)
> > so also, using tuple would improve performance over Lists.
> >
> > is this presumption correct?
> >
>
> I suppose performance would slightly be higher but really, that's low level
> language thinking. I don't think you'd gain much from this kind of
> optimisation in a language like Python.
>
>
> >
> > if it is, then as a practice, If I know the contents of my sequence at
> the
> > time of initialization and the fact that the sequence is not going to
> > change
> > at runtime, would it be always good to use tuples instead of lists.
> >
> > Any views on this one?
> >
>
> Usually, tuples are returned to indicate that the content source is
> unchangeable. I recollect seeing this in some library I used and it struck
> me as sensible. Also, if you want a hashable list (eg. for a dictionary
> key).
>
> There are reasons to use them but performance (YMMV) is not one of them.
>
>
> --
> ~noufal
> http://nibrahim.net.in
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
Thanks and best regards,
Vishal Sapre

---

"So say...Day by day, in every way, I am getting better, better and better
!!!"
"A Strong and Positive attitude creates more miracles than anything else.
Because...Life is 10% how you make it, and 90% how you take it"
"Diamond is another piece of coal that did well under pressure”
"Happiness keeps u Sweet, Trials keep u Strong,
Sorrow keeps u Human, Failure Keeps u Humble,
Success keeps u Glowing, But only God Keeps u Going.Keep Going."
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] can not connect to Mobile Broadband

2009-12-22 Thread BR!j!TH
Sorry

2009/12/23 Pradeep Gowda 

> On Tue, Dec 22, 2009 at 11:55 PM, BR!j!TH  wrote:
>
> >
> >
> > Does any one have any solution this problem ?
> >
> >
> Have you tried configuring it using the "Network Manager" app?
>
> You are on the wrong mailing list. And even if someone does attempt to
> answer, your question does not carry sufficient
> information to help understand the problem. Try again and on a Linux user
> group this time.
>
> Also, Linux User Group is that way -->
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
"Dream is not what you see in sleep
is the thing which does not let you sleep"
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] can not connect to Mobile Broadband

2009-12-22 Thread Pradeep Gowda
On Tue, Dec 22, 2009 at 11:55 PM, BR!j!TH  wrote:

>
>
> Does any one have any solution this problem ?
>
>
Have you tried configuring it using the "Network Manager" app?

You are on the wrong mailing list. And even if someone does attempt to
answer, your question does not carry sufficient
information to help understand the problem. Try again and on a Linux user
group this time.

Also, Linux User Group is that way -->
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] can not connect to Mobile Broadband

2009-12-22 Thread BR!j!TH
Hi Friends,
Does Anyone having problem in  connecting BSNL EVDO (USB modem) broadband to
Ubuntu 9.10. For me it is not working. I am really disappointed because with
out internet I can Install my favorite applications from repository. 9.04 it
was working fine. Now I am thinking to switch back to 9.04.

Does any one have any solution this problem ?


-- 
"Dream is not what you see in sleep
is the thing which does not let you sleep"
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Is it possible to run python software in WinxP?

2009-12-22 Thread Pradeep Gowda
On Tue, Dec 22, 2009 at 11:00 PM, 74yrs old  wrote:

> for download  at website viz  http://code.google.com/p/tesseractindic/. (
> On
> request,  the said  program - shall forward the same to you)
>
> You need GTK2+ libraries and PyGTK
The first one is available at:
http://gtk-win.sourceforge.net/home/index.php/en/Downloads
direct link: (
http://downloads.sourceforge.net/gtk-win/gtk2-runtime-2.16.6-2009-12-01-ash.exe?download
)
and the second one at: http://ftp.gnome.org/pub/GNOME/sources/pygtk/2.14/

Install the GTK2+ using the given exe installer.
The PyGTK tar.gz has to be untarred (unzipped) and inside you will find a
setup.py file

Run
python.exe setup.py install
>From the windows command line (Start->Run->cmd)

after this you will be able to install tesseractindic package and run the
app.

+PG
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Is it possible to run python software in WinxP?

2009-12-22 Thread 74yrs old
Hello Python experts,

I have one python program og (113KB) ( on request, I shall forward the same)
which run sucessfully in Ubuntu 9.04 and Fedora-11. but failed to run in
WinXP even though I have installed python 2.06 and python 3.0
and also GTK 2.0. Since I am newbie to python, I seek your valuable
guidance- step by step-   how to run the said program in WinXP also. The
said program viz "tesseractindic-trainer-gui-0.1.3 tar.gz"(113 KB) is
available
for download  at website viz  http://code.google.com/p/tesseractindic/. ( On
request,  the said  program - shall forward the same to you)

Sine issue is challenging, trust python experts are in position to solve the
problem to run in WinXP successfully also - for which I shall ever thankful
to you.

With Regards,
-sriranga(77yrsold)
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-22 Thread Roshan Mathews
On Tue, Dec 22, 2009 at 9:59 PM, Noufal Ibrahim  wrote:
>  This is an 'intention' rather than an enforced rule isn't it? It does seem
> natural though. I don't think i've ever seen a tuple with elements of
> different types.
>
I use namedtuple for those, (or just plain classes before I knew of that.)

> My thumb rule is if you need an immutable structure (often for a dictionary
> key), use a tuple. Otherwise, use a list.
>
Yeah, that pretty much sums up what I do too.

I googled the links just before I posted, because while I thought that
tuples were faster (I think I used them once for that reason), I
couldn't remember why.

-- 
Roshan Mathews
http://teamtalk.im
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-22 Thread Yuvi Panda
urlpatterns in django use tuples of different types (string, callable), no?

On Tue, Dec 22, 2009 at 9:59 PM, Noufal Ibrahim  wrote:

> On Tue, Dec 22, 2009 at 9:52 PM, Roshan Mathews 
> wrote:
>
> > [..]
> >
> >
> http://jtauber.com/blog/2006/04/15/python_tuples_are_not_just_constant_lists/
> >Tuples are not constant lists -- this is a common
> >misconception. Lists are intended to be homogeneous
> >sequences, while tuples are hetereogeneous data
> >structures.[..]
>
>
>  This is an 'intention' rather than an enforced rule isn't it? It does seem
> natural though. I don't think i've ever seen a tuple with elements of
> different types.
>
> My thumb rule is if you need an immutable structure (often for a dictionary
> key), use a tuple. Otherwise, use a list.
>
>
> --
> ~noufal
> http://nibrahim.net.in
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
Yuvi Panda T
http://yuvi.in/blog
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-22 Thread Noufal Ibrahim
On Tue, Dec 22, 2009 at 9:52 PM, Roshan Mathews  wrote:

> [..]
>
> http://jtauber.com/blog/2006/04/15/python_tuples_are_not_just_constant_lists/
>Tuples are not constant lists -- this is a common
>misconception. Lists are intended to be homogeneous
>sequences, while tuples are hetereogeneous data
>structures.[..]


 This is an 'intention' rather than an enforced rule isn't it? It does seem
natural though. I don't think i've ever seen a tuple with elements of
different types.

My thumb rule is if you need an immutable structure (often for a dictionary
key), use a tuple. Otherwise, use a list.


-- 
~noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-22 Thread Roshan Mathews
On Tue, Dec 22, 2009 at 7:10 PM, Vishal  wrote:
> I was presuming that since tuples are immutable, like strings, and string
> immutability increases performance (
> http://effbot.org/pyfaq/why-are-python-strings-immutable.htm)
> so also, using tuple would improve performance over Lists.

http://stackoverflow.com/questions/68630/are-tuples-more-efficient-than-lists-in-python

http://jtauber.com/blog/2006/04/15/python_tuples_are_not_just_constant_lists/
Tuples are not constant lists -- this is a common
misconception. Lists are intended to be homogeneous
sequences, while tuples are hetereogeneous data
structures.

Tauber's point about tuples being structures named by index, seemed
correct in light of "namedtuple" in collections (since Python 2.6)

Also, as Noufal mentioned, tuples are hashable, so you can use them as
keys in a dict.

-- 
Roshan Mathews
http://teamtalk.im
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-22 Thread Noufal Ibrahim
On Tue, Dec 22, 2009 at 7:10 PM, Vishal  wrote:

> Hi,
>
> I was presuming that since tuples are immutable, like strings, and string
> immutability increases performance (
> http://effbot.org/pyfaq/why-are-python-strings-immutable.htm)
> so also, using tuple would improve performance over Lists.
>
> is this presumption correct?
>

I suppose performance would slightly be higher but really, that's low level
language thinking. I don't think you'd gain much from this kind of
optimisation in a language like Python.


>
> if it is, then as a practice, If I know the contents of my sequence at the
> time of initialization and the fact that the sequence is not going to
> change
> at runtime, would it be always good to use tuples instead of lists.
>
> Any views on this one?
>

Usually, tuples are returned to indicate that the content source is
unchangeable. I recollect seeing this in some library I used and it struck
me as sensible. Also, if you want a hashable list (eg. for a dictionary
key).

There are reasons to use them but performance (YMMV) is not one of them.


-- 
~noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Tuples vs Lists, perfromance difference

2009-12-22 Thread Sidharth Kuruvila
Hi,
  I don't think you should see and difference in performance. Lists
might take a bit more space since they usually preallocate memory for
future inserts.

  I'd go for lists where ever i need to use an array or a list, and
tuples for storing records.

Regards,
Sidharth



On Tue, Dec 22, 2009 at 7:10 PM, Vishal  wrote:
> Hi,
>
> I was presuming that since tuples are immutable, like strings, and string
> immutability increases performance (
> http://effbot.org/pyfaq/why-are-python-strings-immutable.htm)
> so also, using tuple would improve performance over Lists.
>
> is this presumption correct?
>
> if it is, then as a practice, If I know the contents of my sequence at the
> time of initialization and the fact that the sequence is not going to change
> at runtime, would it be always good to use tuples instead of lists.
>
> Any views on this one?
>
> Thanks and best regards,
> Vishal Sapre
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
I am but a man.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Tuples vs Lists, perfromance difference

2009-12-22 Thread Vishal
Hi,

I was presuming that since tuples are immutable, like strings, and string
immutability increases performance (
http://effbot.org/pyfaq/why-are-python-strings-immutable.htm)
so also, using tuple would improve performance over Lists.

is this presumption correct?

if it is, then as a practice, If I know the contents of my sequence at the
time of initialization and the fact that the sequence is not going to change
at runtime, would it be always good to use tuples instead of lists.

Any views on this one?

Thanks and best regards,
Vishal Sapre
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python performance

2009-12-22 Thread Senthil Kumaran
On Tue, Dec 22, 2009 at 02:01:47PM +0530, Venkatraman S wrote:
> Are you sure about this? As in, multithreading *in* python does help?

Yes, very much. It is a prevalent misunderstanding that
multi-threading in python does not help at all. For IO operations like
reading a file, listening and reading from a socket, multi threading
is pretty fine.


-- 
Senthil
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python performance

2009-12-22 Thread Noufal Ibrahim
On Tue, Dec 22, 2009 at 2:01 PM, Venkatraman S  wrote:

> [..]



> Are you sure about this? As in, multithreading *in* python does help?
>

For I/O bound operations, it does help.


-- 
~noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python performance

2009-12-22 Thread Ramdas S
On Tue, Dec 22, 2009 at 2:01 PM, Venkatraman S  wrote:

> On Tue, Dec 22, 2009 at 1:58 PM, Senthil Kumaran  >wrote:
>
> >
> > Have you done multithreading? If yes, thinking of implementing
> > the file read operations in separate threads and this should improve
> > the performance as number of threads increase.
> >
> >
> Are you sure about this? As in, multithreading *in* python does help?
> Never tried it. Sounds interesting.
>


I haven't  never tried multi-threading. Its never worked for me.

> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
Ramdas S
+91 9342 583 065
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] MysqlDB ; delete and select issue

2009-12-22 Thread Santhosh Edukulla
Hi Team,

Can somebody please comment on the query posted at the below link?

http://stackoverflow.com/questions/1922623/mysqldb-python-module

See the last post to the thread from me for more information.

Any help is highly appreciated.


Thanks in Advance!
Santhosh
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python performance

2009-12-22 Thread Venkatraman S
On Tue, Dec 22, 2009 at 1:58 PM, Senthil Kumaran wrote:

>
> Have you done multithreading? If yes, thinking of implementing
> the file read operations in separate threads and this should improve
> the performance as number of threads increase.
>
>
Are you sure about this? As in, multithreading *in* python does help?
Never tried it. Sounds interesting.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python performance

2009-12-22 Thread Senthil Kumaran
On Tue, Dec 22, 2009 at 01:25:17PM +0530, Ramdas S wrote:
> I saw this doc and  a few other docs online.
> 
> http://wiki.python.org/moin/PythonSpeed/PerformanceTips

Just follow this. This one seems good.

> I/O. I have a program that opens between 4 to 7 text files in memory to

Have you done multithreading? If yes, thinking of implementing
the file read operations in separate threads and this should improve
the performance as number of threads increase.

-- 
Senthil
Whoever dies with the most toys wins.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python performance

2009-12-22 Thread Noufal Ibrahim
On Tue, Dec 22, 2009 at 1:25 PM, Ramdas S  wrote:

> Dear all,
>
> I saw this doc and  a few other docs online.
>
> http://wiki.python.org/moin/PythonSpeed/PerformanceTips
>
>
> Are there any recommendations on how I can improve performances in case of
> I/O. I have a program that opens between 4 to 7 text files in memory to
> analyze data. It runs beautifully on some 100 odd lines of Python code, but
> its quite slow, sometimes taking a few more seconds than desired.
>
> Is there any generic tips out there?
>

You can get some performance out of manually reviewing the code. If it's a
first draft, there will probably be chances for improvement (caching,
removing recomputation etc.).

I haven't really tried/measured it but you can use the -O option to the
interpreter to optimise the generated bytecode a little.

If you're running on a 32 bit machine, it might make sense to use the psyco
JIT http://psyco.sourceforge.net/. I don't think it's maintained though
(Armin Rego has to moved to PyPy) and I don't know how much it will help you
with I/O bound apps.

Finally, use a profiler http://docs.python.org/library/profile.html to find
out where the hotspots are in your code and squeeze them a little. If you
find a place which is really killing performance, it might make sense to
sacrifice some portability and move it to C or something low level.


-- 
~noufal
http://nibrahim.net.in
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers