Re: LARGE numbers

2005-11-11 Thread Alex Martelli
, I'd like to point out that the speed difference isn't all that large, if all you're doing is ordinary arithmetic -- a few times at most (it can be better if you need some of GMP's functionality which gmpy exposes, such as primality testing). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Import statements for timeit module

2005-11-11 Thread Alex Martelli
ChaosKCW <[EMAIL PROTECTED]> wrote: > So timeit is mostly useless then ? No, it's a precious jewel, but if you want to use it you must allow it to import the code you want it to run. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: derived / base class name conflicts

2005-11-11 Thread Alex Martelli
In general, such coupling being strong, knowing the full API of the base class is inevitable (although in some special corner-case, when you do only need to add private data, you may, exceptionally, get away with less knowledge). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a built-in method for transforming (1, None, "Hello!") to 1, None, "Hello!"?

2005-11-11 Thread Alex Martelli
rhaps you can clarify exactly what you're asking for! Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-11 Thread Alex Martelli
David Gutierrez <[EMAIL PROTECTED]> wrote: > Include me in your list, please. Uh, what list? If you mean gmpy-commits, you subscribe to it on gmpy.sf.net -- if you mean the general Python list, on www.python.org. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-11 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... > Excellent work guys! > > Not only is the divm() bug fixed but it looks like we got a > significant performance increase. Thanks! Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically Update Class Definitions?

2005-11-11 Thread Alex Martelli
ces of old_class and "somehow" change their classes to new_class -- of course, x.__class__ = new_class may well not be sufficient, in which case you'll have to pass to update a callable to do the instance-per-instance job. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-11 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 10 Nov 2005 21:41:52 -0800, Alex Martelli wrote: > > >> Obfuscation has it's place. > > > > What I think of this thesis is on a par of what I think of this way of > > spelling the posse

Re: Python obfuscation

2005-11-12 Thread Alex Martelli
Yu-Xi Lim <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > There is no effective manner of protecting your code, except running it > > only on well-secured machines you control yourself. If you distribute > > your code, in ANY form, and it's at all interestin

Re: Python obfuscation

2005-11-12 Thread Alex Martelli
Yu-Xi Lim <[EMAIL PROTECTED]> wrote: > I hadn't seen any damage done from misusing "it's". Certainly not on par You should see my pharmacy bill for Maalox... and my liver ain't too happy about it either;-) Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-12 Thread Alex Martelli
ded by one model that has worked sort of decently for a small time in certain sets of conditions, into believing that model is the only workable one today or tomorrow, with conditions that may be in fact very different. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Hash map with multiple keys per value ?

2005-11-12 Thread Alex Martelli
crete example (which likely has bugs, being untested, and even more likely misinterpret some specs, since I'm having to guess at quite a few details) you can nail down the exact kind of API syntax and semantics that you require...? Once the specs are entirely clear, we might (if needed) worry about efficiency, but that seems somewhat premature at this stage... Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Hash map with multiple keys per value ?

2005-11-12 Thread Alex Martelli
^^ > > Will that end up with two(many) references to the same set? [Though in any > case I would be iterating over all values in the set). Yes, but it's buggy (doesn't modify the self.d[z] entries for all the z's which aren't either x nor y but alias either of them). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-12 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > In a competitive marketplace, why would I choose to buy DRMed software if > there is a non-DRMed equivalent with the same functionality and equivalent > cost? The only explanation I can think of is, their marketing must be AWEsom

[ANNOUNCE] gmpy 1.1 beta released

2005-11-13 Thread Alex Martelli
GMP). This release has no known bugs (the scan0/scan1 bug that used to be present in Windows binary releases, as predicted, has disappeared without needing any changes to gmpy, thanks to bug fixes in GMP; the divm function's bugs, that were gmpy's responsibility, are now fixed). A

Re: Copyright [was Re: Python Obfuscation]

2005-11-13 Thread Alex Martelli
fy? The movie industry was born in California to skirt around some of Edison's (and others') patents, but that's a whole 'nother story, of course. Alex -- http://mail.python.org/mailman/listinfo/python-list

gmpy 1.01 binaries for the mac

2005-11-13 Thread Alex Martelli
or them, I _am_ rather full of Macs (& dev systems for them;-)... Alex -- http://mail.python.org/mailman/listinfo/python-list

gmpy/decimal interoperation

2005-11-13 Thread Alex Martelli
ecome a Decimal, just like an int would, so that the result is a Decimal) and which ones should only happen on explicit request (e.g., gmpy.mpf(d) should produce an mpf instance, just as calling gmpy.mpf on an int instance would). Alex -- http://mail.python.org/mailman/listinfo/python-list

multiple inharitance super() question

2005-11-14 Thread Alex Greif
(A,AA): def __init__(self, args): super(B, self).__init__(args) How can I tell that B.__init__() should initialize A and AA? Or is the new super() so clever to call A.__init__() and AA.__init__() internally? thanks, Alex Greif http

Re: want some python ide

2005-11-14 Thread alex . greif
Hi, look for SciTE http://www.scintilla.org/SciTE.html it is small, fast and lightweight Alex Greif http://www.fotobuch-xxl.de/ D H wrote: > [EMAIL PROTECTED] wrote: > > i want some python ide use pygtk > > eric3 is good for me ,but i lik

Re: gmpy/decimal interoperation

2005-11-14 Thread Alex Martelli
'upgraded' to mpq (with a Stern-Brocot heuristic), but it wouldn't be any harder to have the mpq 'degrade' to float instead. Alex -- http://mail.python.org/mailman/listinfo/python-list

best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread Alex Martelli
as not recurred, as cross-platform as feasible? In particular, how would you code _memsize() "cross-platformly"? (I can easily use C rather than Python if needed, adding it as an auxiliary function for testing purposes to my existing extension). TIA, Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: compare list

2005-11-14 Thread Alex Martelli
and 0; if you need to fix this last issue, you can add an int(...) call around these booleans in either of the functions in question. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Not sure if I should start a new thread or not, but > since this is closely related, I'll just leave it as is. > > Alex Martelli wrote: > > > Having fixed a memory leak (not the leak of a Python reference, s

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-15 Thread Alex Martelli
Neal Norwitz <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > > So, I thought I'd turn to the "wisdom of crowds"... how would YOU guys > > go about adding to your automated regression tests one that checks that > > a certain memory leak

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-15 Thread Alex Martelli
trusage, which would be the obviously right way to do it, as such a useless empty husk (as far as memory consumption is concerned). Ah well!-( Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Default method arguments

2005-11-15 Thread Alex Martelli
, you can, if you wish, get as fancy as you desire -- the next level of complication beyond the simple factory above is to turn f into a custom descriptor and play similar tricks in the __get__ method of f (after which, one can start considering custom metaclasses). Exactly because Python's rules and building blocks are simple, clean, and sharp, you're empowered to construct as much complication as you like on top of them. That doesn't mean you SHOULD prefer complication to simplicity, but it does mean that the decision is up to you. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-15 Thread Alex Martelli
ementary question "how much virtual memory is this process using right now?"...!), since I definitely cannot drop support for all PPC-based Macs (nor would I WANT to, since they're my favourite platform anyway). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-15 Thread Alex Martelli
s ARE online. Thanks again! Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: is parameter an iterable?

2005-11-15 Thread Alex Martelli
n a bodyless loop to prove that > you can iterate before doing the real thing because not all iterators > are idempotent. It's not hard...: try: _it = iter(whatever) except TypeError: print 'non-iterable' else: for i in _it: # etc, etc Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: So what are __slots__ and when should I use them?

2005-11-15 Thread Alex Martelli
ge, rather than using Python as Python). However, I heartily recommend that you consider defining __slots__ only as an optimization (memory saving), should you ever find yourself in a situation meeting all of the requirements in the previous paragraph (if ever). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-16 Thread Alex Martelli
be setuid or setgid. It does so in a module that's 300+ lines of ObjectiveC, so it would require quite a bit of reverse engineering to integrate into a pure-C Python extension, but at least it serves as proof of existence;-) Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: AJAX => APAX? Or: is there support for python in browsers?

2005-11-16 Thread Alex Martelli
ed, so the ``script'' could easily do any arbitrary damage to the machine... Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-16 Thread Alex Martelli
ething that would normally be called "a memory leak" -- unless I'm failing to see some cross-platform scenario that would erroneously re-load the same library over and over again, taking up growing amounts of shared memory with time? Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-16 Thread Alex Martelli
lopment project failed disastrously (after some code got written but before it got deployed, i.e., distributed), as so many projects in the SW industry do (at various stages of the development process). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-16 Thread Alex Martelli
ide deployment... but it would be just as vulnerable as a wholly client-side deployment to issues of [lack of] disaster planning etc). So, I may perhaps be misunderstanding what you're saying about "my solution"...? Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-17 Thread Alex Martelli
ctions worse than I could have given, in this context, seems a deliberate self-sabotage without any return. > what's the current exchange rate for clicks and dollars? As far as I know, it varies wildly depending on the context, but I suspect you can find ranges of estimates on the web. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Simulating call-by-reference

2005-11-17 Thread Alex Martelli
c. I think you mean the Bunch idiom, rather than the Borg one (which has to do with having instances of the same class share state). Personally, I would rather pass myvar as well as the attribute names, and set them with setattr, as I see some others already suggested. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: about try and exception

2005-11-17 Thread Alex Martelli
n(q)): > print test(q[i],q[i+1],q[i+2]) put the try/except around the print statement (you'll also need to decide whether you also want to catch the IndexError you'll get towards the end of the sequence, of course;-). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing a class without knowing the module

2005-11-17 Thread Alex Martelli
ts BEFORE the text you're commenting on?!), but anyway I think that using the class's __module__ rather than __file__ should be what you want. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing a class without knowing the module

2005-11-17 Thread Alex Martelli
ou use Foo.__module__, you should get the *module* name correctly, independently from sys.path or __init__.py's, or .pth files for that matter -- so, I do NOT agree that using __file__ is "about the best you can do" for this use case. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing a class without knowing the module

2005-11-17 Thread Alex Martelli
e__ attribute) but not about its module (by a __module__ attribute), I would of course hope that my inability to parse that sentence of yours, which would under such hypothetical circumstaces be an absurd hypothesis, might be more forgivable. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Hot to split string literals that will across two or more lines ?

2005-11-17 Thread Alex Martelli
these assigments use parentheses (after the = and at line end), it's the comma that does make all the difference. So, you can see it as a very good side effect of the "long string use parentheses, not backslashes" style rule, that the reader is soon weaned of the mistake of believing that parentheses signify tuples. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing a class without knowing the module

2005-11-18 Thread Alex Martelli
r own good, and let them deal with the situation. But as I said, that may depend on a failure of the imagination -- if you can show me compelling use cases in which heuristics on __file__ prove perfectly satisfactory where just dealing with __name__ wouldn't, I'm quite ready to learn! Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-18 Thread Alex Martelli
they have been repeatedly shown to be potentially quite effective -- so, I'm hoping there will be no debate that the segmentation might perfectly well be appropriate for this "analogy" case, whether it is or isn't in the originally discussed case of selling predictions-via-webservices). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Speeding up multiple regex matches

2005-11-18 Thread Alex Martelli
nded number of regexes to start with you'll have to split them up 99-or-fewer at a time, but that shouldn't be impossibly hard. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing a class without knowing the module

2005-11-18 Thread Alex Martelli
ame object that's available under that class's name from the module it belongs to -- otherwise (e.g., for classes dynamically defined inside a function), it raises a PicklingError. As a general point, refusing to marshal data that strongly smells like it will be hard or unlikely to unmarshal later is commendable prudence, and I would recommend this general, prudent approach strongly. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing a class without knowing the module

2005-11-18 Thread Alex Martelli
fully agree that trying to be helpful, per se, is never inherently blameworthy, whether one succeeds or fails in the attempt -- so, thanks for your many (and mostly better based than this one) attempts to be of help to c.l.py posters. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about namespaces

2005-11-18 Thread Alex Martelli
uch "outside imports"? I don't see the need for any checks. If you just simply forget the very _existence_ of "from X import *", your Python code can only grow better as a result. I earnestly hope it disappears come Python 3.0 time... Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-19 Thread Alex Martelli
. Since redistribution of value, as long as a lot of value is created, can be dealt with by other means, maximizing the creation of value tends to be the goal I prefer -- a policy that quashes part or all of value creation based on redistributive precepts is, by this very fact, going to be something I look askance at (making the pie smaller to try to ensure that what little is left gets sliced according to your political preferences, rather than ensuring the pie is as big as possible as the first order of business, and dealing with the slicing issues as _secondary_ ones). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: How to write an API for a Python application?

2005-11-19 Thread Alex Martelli
several implementations of mutually compatible clients and servers for that same echo-oid "protocol" (as well as one incompatible one using UDP -- all the others use TCP). I hope they can be useful to anybody wanting to kludge together some simple TCP/IP thingy (though, for the problem

Re: Confused about namespaces

2005-11-19 Thread Alex Martelli
decision. It's a construct that I sometimes find quite handy in an experimentation session in the interactive interpreter, but just has no really good place in 'true' code;-0. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-20 Thread Alex Martelli
ry in instances of that custom type... having such instances compare with each other based on the index within preferred_fields of the key they're wrapping, etc etc). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-20 Thread Alex Martelli
'ordered dict' which does NOT match your one unambiguous definition...;-) If the field of use cases for 'ordered dicts' is just too fragmented, it's quite possible that it's best not to have any single kind built-in, even though, could all different use cases be combined (which by hypothesis is unfeasible), "critical mass" would be reached... Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-20 Thread Alex Martelli
" Ah, but WHAT 'some criteria'? There's the rub! First insertion, last insertion, last insertion that wasn't subsequently deleted, last insertion that didn't change the corresponding value, or...??? Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-21 Thread Alex Martelli
return _aux.get(k, _l) It's very unlikely that this situation warrants such optimization, of course, I'm just "thinking aloud" about abstract possibilities. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Numeric array in unittest problem

2005-11-21 Thread Alex Martelli
t;> c array([1, 0]) >>> assert(c) i.e., thanks to element-by-element evaluation, == will generally return a true value for ANY comparison of Numeric arrays, causing a very frequent beginner's bug to be sure. Try Numeric.alltrue(c), or Numeric.allclose(a,b) ... Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-21 Thread Alex Martelli
Fredrik Lundh <[EMAIL PROTECTED]> wrote: ... > ("but assume that I have some other use case" isn't a valid use > case) +1 QOTW Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-21 Thread Alex Martelli
ady have a complete distro available, while initially nobody would have the package, but if we measure when things settle, after letting a month of two or 'transient' pass, that effect might be lessened. If we ran such an experiment, what fraction do you think would serve to convince Guido that a dict 'ordered' by your definition is necessary in Python 2.5's standard library (presumably in module 'collections')? Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Backwards compatibility [was Re: is parameter an iterable?]

2005-11-21 Thread Alex Martelli
e sure that you're getting paid for this in proportion to its ugliness, and your finances should be set for life. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: ownership problem?

2005-11-21 Thread Alex Martelli
ecause cleanup still has to be done, so it > just ends up getting moved outside the objects where it belongs. I > think this hurts abstraction. Python 2.5 should introduce a 'with' statement that may go partways towards meeting your qualms; it's an approved PEP, though I do not recall its number offhand. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
discovered by Stigler...;-). The Poisson distribution was in fact described earlier by Bernoulli, Gosset's z-test is universally known as Student's t-test, etc, etc. Salsburg's delightful "The Lady Tasting Tea" has a lot of fun with Stigler's law in the footnotes...;-) Ale

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Alex Martelli schrieb: > > Perl hashes now keep track of 'order of keys'? That's new to me, they > > sure didn't back when I used Perl! > > Maybe I shouldn't have talked about Perl when I&#

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
I agree that a dictionary subclass that's ordered based on insertion timing would have more added value than one where the 'ordering' is based on any function of keys and values. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
ave the name of the new container reflect this, with a specific mention of *insertion* order... rather than just call it "ordered" and risk probable confusion. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: about sort and dictionary

2005-11-22 Thread Alex Martelli
indicate that the method is a mutator. So, you can have a.reverse [NOT mutating a since no !] _and_ a.reverse! [mutating a]. Probably too much of a change even for Python 3000, alas... but, it DOES make it obvious when an object's getting mutated, and when not... Alex -- http://mail.pytho

Re: about sort and dictionary

2005-11-22 Thread Alex Martelli
rather off-topic. Yep. If you disagree so deeply with Python's foundations, other language such as Perl, embodying just the "striving" you cherish, should probably make you much happier. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
uld be the result of arbitrary permutation, e.g., > > manual shuffling, etc. Of course either way, a result can be said > > to have a particular defined order, but "sorted" gets ordered > > by sorting, and "ordered" _may_ get its order by any means. > > >

Re: the name of a module in which an instance is created?

2005-11-22 Thread Alex Martelli
Untested code, but the general idea should work. You could try to hack this without a custom metaclass, e.g. by trying sys._getframe in __init__, but that's fragile since the __init__ could be called by a *subclass* in whatever module... Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
f your wrapper or subclass. That's a pretty obvious difference from cases in which the auxiliary table used to define the ordering is REALLY *separate* -- independent of the insertion/etc history of the dictionaries it may be used on. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: about sort and dictionary

2005-11-23 Thread Alex Martelli
for example that S is a mutable string, in being able to name some of S's methods as: upper return an uppercased copy of S, not mutating S upper! mutate S in-place to be uppercased upper? return True iff S is already uppercased, not mutating S but (maybe because I have no extensive Ruby re

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Alex Martelli
orm list operations on the ``sequence`` attribute of > course. But NOT having to expose .sequence as a real mutable list whose changes affect ordering has many advantages, as above noticed. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Alex Martelli
ly accomplished by slicing of course, d[-5:] and d[:3] respectively. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: about sort and dictionary

2005-11-23 Thread Alex Martelli
ator I must memorize or work out (or guess) whether the author considered its mutation "surprising or destructive" to know whether I need to append a bang or not, which is peeving; so, I'm now happily reconciled to Python never adopting this. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Making immutable instances

2005-11-23 Thread Alex Martelli
when you're initializing your istance, so remember to delegate attribute setting to the superclass (the other special methods mentioned above are less likely to byte you). You will probably want to define __hash__ and __eq__ if you're going to the trouble of making instances immutable.

Re: (newbie) N-uples from list of lists

2005-11-23 Thread Alex Martelli
recursive";-) ]] An example of recursion elimination in Python can be found at <http://mail.python.org/pipermail/python-list/2002-January/082481.html> Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: (newbie) N-uples from list of lists

2005-11-23 Thread Alex Martelli
state, so it can be faster) fully including the "obfuscation" typical of optimizations;-) Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: ... > d.ksort() = d.sortkeys() > d.asort() = d.sortvalues() > > d.sort() could default to one of them (not sure which one). Define JUST d.sort, you can trivially implement the other as d.sort(key=d.get). Alex -- http://mail.

Re: Making immutable instances

2005-11-23 Thread Alex Martelli
. def __setattr__(*a): raise TypeError, 'immutable' ... def __init__(self, v=23): ... super(Immut,self).__setattr__('v', v) ... >>> x=Immut() >>> x.v 23 >>> x.v=42 Traceback (most recent call last): File "", line 1, in ? File "", line 2, in __setattr__ TypeError: immutable >>> Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Making immutable instances

2005-11-23 Thread Alex Martelli
striction would have changed my answer (although an explicit acknowlegment that you're looking for restrictions against accidental misuse rather than against determined attackers surely would). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: defining the behavior of zip(it, it)

2005-11-23 Thread Alex Martelli
;> d[:] Traceback (most recent call last): File "", line 1, in ? TypeError: sequence index must be integer >>> deque(d) deque([1, 2, 3]) >>> I.e., NOT all sequences implement the unreadable x[:] form. The way that DOES work with all sequences is typeyouwant(sequence). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Making immutable instances

2005-11-24 Thread Alex Martelli
f experience as a consultant, both freelance and "in-house" within large organizations... Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: about sort and dictionary

2005-11-24 Thread Alex Martelli
Magnus Lycka <[EMAIL PROTECTED]> wrote: ... > > I think you mean volatile or mutable rather than transient? "transient" ... > Right, volatile it is. It's really great that I can program so much > Python now that I forget my C++! :) Thanks Alex (both

Re: Making immutable instances

2005-11-24 Thread Alex Martelli
more cumbersome, they can get the same semantics this way, even though it may seem "inside-out" wrt the "intuitive" approach. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Alex Martelli
a basic data type in the beginning, with lists, > tuples, dictionaries as derived data types. You appear to have a strange notion of "derived data type". In what sense, for example, would a list BE-A set? It breaks all kind of class invariants, e.g. "number of items is identical to number of distinct items", commutativity of addition, etc.. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: about sort and dictionary

2005-11-24 Thread Alex Martelli
Magnus Lycka <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > I don't think these headaches and difficulties justify dumping the whole > > field of reasoning about programs, nor the subfield of PbC. The concept > > of "immutable" is really just

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Alex Martelli
res a different mindset, particularly when operating under a regime of "mutable" objects. "A circle IS-AN ellipse" in Euclidean geometry... but inheriting Circle from Ellipse doesn't work in OO if the objects are changeable, since you can, e.g., change eccentricity in an Ellipse but not in a Circle... Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > An alternative theory, of course, is "God made the natural numbers; all > > else is the work of man" -- and that one is by a German, too (Kronecker, > > if I recall correctl

Re: defining the behavior of zip(it, it)

2005-11-24 Thread Alex Martelli
en you know you start with a list instance and want a shallow copy thereof, but I see no good reason to specialcase this occurrence AND use an unreadable idiom in it, when the nice, general, readable idiom is perfectly serviceable. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Making immutable instances

2005-11-24 Thread Alex Martelli
o make its number types mutable, thinking this might probably enhance performance, but I double checked with Python cognoscenti first -- and the result was a plebiscite for IMmutable numbers (at the time, I was sort of new at Python, and didn't really get it, but now I do;-). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-25 Thread Alex Martelli
es of an mmap are instances of str, not of mmap, if I recall correctly), most sliceable sequences do follow that pattern. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic classes

2005-11-25 Thread Alex Martelli
do this in a loop's body. Creating new classes is a reasonably rare need, creating new instances is a very common need. Perhaps you can clarify which one you mean? Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Persist a class (not an instance)

2005-11-25 Thread Alex Martelli
you'd need a custom metaclass to use as the type for your "picklable classes". Moreover, if the class has attributes that you also want to pickle, such as methods or properties, you'll have to arrange for custom pickling of *them*, too. So, yes, there are ways, but not simple

Re: wxPython Licence vs GPL

2005-11-25 Thread Alex Martelli
by some specific category may be legal (depending on jurisdiction and exact definition of category) but they're definitely not open-source, by definition of the latter. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython Licence vs GPL

2005-11-25 Thread Alex Martelli
used to make profits from software sales before they got gobbled up). I think SAP and Adobe aren't doing badly, either, but I haven't checked up on them in a while. I'd be surprised if there weren't many relative minnows that I didn't think of, beyond the few "obvious

Re: wxPython Licence vs GPL

2005-11-26 Thread Alex Martelli
iece of advice: *don't short the SW-sales sector*, you could really be taken to the cleaners. Your perceptions of even the major players in the sector are clearly wrong, and appear to be based on extremely poor research, or even at times no research at all. I'm not saying that software sales have a bright mid-long term future, but when you're talking about the present and short term future, it's demonstrable that your perception of the market sector is way wrong; so I earnestly advise you to NOT put your money where your mouth is, lest you end up losing a large fraction of that money. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparison problem

2005-11-26 Thread Alex Martelli
acter of s (if any)" can be compactly expressed with "s=s[:-1]" rather than "s=s and s[:-1]" or more expansive testing. No big deal, but then again I don't recall any situation in which getting an exception from slicing (as opposed to indexing) would have helped me catch a bug faster. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython Licence vs GPL

2005-11-27 Thread Alex Martelli
the program just downloaded is a hobbled "demo" version? If you want to really USE it, you buy a license which comes with a code to unlock full functionality -- and it so happens the license costs $99. Why do you think it is a crucial distinction as to whether the $99 are forked over to enable the download itself, or just AFTER the download to make the just-downloaded bits useful? Looks like an irrelevant detail to me if I ever saw one... Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Estimating memory use?

2005-11-27 Thread Alex Martelli
Roy Smith <[EMAIL PROTECTED]> wrote: ... > Is there any easy way to find out how much memory a Python object takes? No, but there are a few early attempts out there at supplying SOME ways (not necessarily "easy", but SOME). For example, PySizer, at <http://pysi

Re: should python have a sort list-map object in the std-lib?

2005-11-27 Thread Alex Martelli
sorted() function? Depends on the patterns of occurrences of insertions and deletions versus needs to use the sortedlist, in terms of how do they get bunched or spread out in time wrt each other. For many cases, the best answer is, neither of those you mentioned, but rather the functions in heapq. Alex -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   9   10   >