Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78722 > unrolled thread

Re: re search through a text Vs line

Started byDave Angel <davea@davea.name>
First post2014-10-05 16:12 -0400
Last post2014-10-06 00:46 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: re search through a text Vs line Dave Angel <davea@davea.name> - 2014-10-05 16:12 -0400
    Re: re search through a text Vs line wxjmfauth@gmail.com - 2014-10-06 00:46 -0700

#78722 — Re: re search through a text Vs line

FromDave Angel <davea@davea.name>
Date2014-10-05 16:12 -0400
SubjectRe: re search through a text Vs line
Message-ID<mailman.14616.1412539811.18130.python-list@python.org>
Shiva <shivaji_tn@yahoo.com.dmarc.invalid> Wrote in message:
> OK,
> Hi Dave,
> 
> I modified it as below and it works....(If there is a way to make this more
> efficient please let me know)
> 

Deends on what you mean by efficiency. 

The big memory efficiency gain was when you got rid of either the
 read or readlines.

Performance is pretty irrelevant,  since disk I/O, unicode
 processing,  and terminal processing are likely to
 dominate.

Programmer efficiency is usually more important than either of those.

First thing is to pick better names, and/or comment what the
 cryptic names mean. And avoid any names that look like
 numbers.

Next are to add in the shebang and encoding commands.

You could replace
   fileextract = open(fullfilename,'r')

With
    with  open(fullfilename,'r') as fileextract:

And indent the code that uses the file. That way it's clearer, you
 don't need the separate close, and it will be closed no matter
 how you leave that scope,  whether a return statement or
 exception.

Finally you could indent by 4 spaces instead of 1.

HTH


-- 
DaveA

[toc] | [next] | [standalone]


#78744

Fromwxjmfauth@gmail.com
Date2014-10-06 00:46 -0700
Message-ID<5cae320b-b2ba-41e0-a4b1-3f9a3361777f@googlegroups.com>
In reply to#78722
Le dimanche 5 octobre 2014 22:10:56 UTC+2, Dave Angel a écrit :
> 
> Performance is pretty irrelevant,  since disk I/O, unicode
> 
>  processing,  and terminal processing are likely to
> 
>  dominate.
> 

If unicode is so important, why does Python do the
opposite of the implementation of the coding schemes
endorsed by Unicode.org (memory and performance).

jmf

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web