Re: [Python-Dev] Remove str.find in 3.0?
On 2005-08-26, Terry Reedy <[EMAIL PROTECTED]> wrote: > Can str.find be listed in PEP 3000 (under builtins) for removal? > Would anyone really object? > With all the discussion, I think you guys should realize that the find/index method are actually convenient function which do 2 things in one call: 1) If the key exists? 2) If the key exists, find it out. But whether you use find or index, at the end, you *have to* break it into 2 step at then end in order to make bug free code. Without find, you can do: if s in txt: i = txt.index(s) ... else: pass or: try: i = txt.index(s) ... except ValueError: pass With find: i = txt.index(s) if i >= 0: ... else: pass The code is about the same except with exception, the test of Exception is pushed far apart instead of immediately. No much coding was saved. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] partition() (was: Remove str.find in 3.0?)
On 2005-08-30, Anthony Baxter <[EMAIL PROTECTED]> wrote: > On Tuesday 30 August 2005 11:26, Raymond Hettinger wrote: >> > My major issue is with the names - partition() doesn't sound right to >> > me. >> >> FWIW, I am VERY happy with the name partition(). > > I'm +1 on the functionality, and +1 on the name partition(). The only other > name that comes to mind is 'separate()', but > a) I always spell it 'seperate' (and I don't need another lamdba ) > b) It's too similar in name to 'split()' > trisplit() ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python 3 design principles
On 2005-09-01, Ron Adam <[EMAIL PROTECTED]> wrote:
> As for functions without '()'s. (Just a thought) You could use '<<' or
> '<<<' (or other symbol) as a way to move data between objects.
>
> ui.write <<< 'Hello World/n' # ui.write('Hello World/n')
>
> ui.writeln <<< counter# ui.writeln(counter.next())
>
> ok = ui.input <<< 'press a key:' # ok = ui.input('press a key:')
>
> The requirement could be that the item on the left is a callable, and
> the item on the right is a sequence or generator.
>
Please don't abuse symbols. Perl's ways of symbols all the way without
intuitive meaning is bad. Use descriptive methods and functions please.
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Problems with the Python Memory Manager
On 2005-11-16, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: >>I seemed to have misunderstood the discussion. Was the original user >>accessing and saving copies of many millions of these doubles? >> > He *was* accessing them (therefore generating a call to an array-scalar > object creation function). But they *weren't being* saved. They were > being deleted soon after access. That's why it was so confusing that > his memory usage should continue to grow and grow so terribly. > > As verified by removing usage of the Python PyObject_MALLOC function, it > was the Python memory manager that was performing poorly. Even though > the array-scalar objects were deleted, the memory manager would not > re-use their memory for later object creation. Instead, the memory > manager kept allocating new arenas to cover the load (when it should > have been able to re-use the old memory that had been freed by the > deleted objects--- again, I don't know enough about the memory manager > to say why this happened). Well, the user have to call garbage collection before the memory were freed. Python won't free memory when it can allocate more. It sucks but it is my experience with python. I mean when python start doing swap on my machine, I have to add manual garbage collection calls into my codes. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
