| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Comments:
<0> das_netz: ouch <1> das_netz: why are you translating to C++? why not just write python extensinos? <0> Jerub: probably has to do with the "don't know python" :) <2> i dont know python :) <3> deltab: ahhhh, I didn't notice the difference between exit status and exit code. <1> das_netz: so why are you changing it? is the code not working? not fast enough? <2> Jerub, im interesting only of part of code <0> is "float('inf')" guaranteed to do... something reasonable? or do i need to define something like inf = 1.0e999? <0> or i guess a better question would be, what is the most pythonic way of getting A Big Float <4> a lil ship <5> mcmillen: Python doesn't guarantee *anything* involving infinity and signed zeros. <5> I think it's actually writeen somewhere in the doc. <0> sanxiyn: so for all i know, inf < 0? <5> mcmillen: In practice, Python tries to its best to preserve 754 when underlying platform does. <5> That's my understanding. <0> sanxiyn: ok, well, i will use float('inf') then. but make sure to include a unittest with some sanity, so that if odd things happen on a given platform, it'll be obvious up front
<6> how do i use a win32api function that's not in win32all? <5> mcmillen: I guess... I think you will need to detect underlying platforms. <7> I'm puzzled, why wouldn't inf be guaranteed to be bigger than all representable floats? <8> hi <5> mcmillen: FWIW, I've seen 1e200 * 1e200 used as infinity in some reputable Python programs. <5> Can't recall name out of my head though <0> sanxiyn: i'm considering using cl*** inf: def __gt__(self, other): return True :p <1> mcmillen: you know infinity is both positive and negative, right? <5> mcmillen: Ah, surely that's much easier, if you don't need real 754 infinity. <9> fpconst doesn't work for you? <0> Jerub: yes, all i really care about is initializing a weight so that i can compare something like "if newWeight < weight: weight = newWeight" <0> (in a loop obviously) <1> uh. <0> what is fpconst? <7> sanxiyn: what would real 754 infinity provide? <1> what about just weight = min(weight, newweight) <0> Jerub: then what do i set the initial value of weight to? <5> mcmillen: Initialize it with None and test for it. <0> sanxiyn: ew, ugly, that's what i'm trying to avoid <5> Well, okay. <7> mcmillen: or min(all_weights) <0> kjetilho: the weight comparison happens in the middle loop of a 3-loop computation, all the weights won't even fit into memory <7> heh <5> Hm, it was Tim Peters who recommended 1e200*1e200, so probably it works. <0> unless n < 500 or so <5> (Python SF 971200) <8> if weight is None: weight = newWeight ; # get more weight input and then do ; weight = min(weight, newWeight) <8> i don't see why you can't just check for None just once and then start a loop <8> or, rather.. <7> sanxiyn: but 1e200*1e200 == float('inf') ... <8> get a couple weights, one into "weight" and one into "newWeight" and then start the loop <0> Vratha: weight of stuff on the "inside" might also be infinity (in fact most values are probably infinity at first), so i need to check for none explicitly every time. my point was to do something more concise rather than adding an "if" statement <5> kjetilho: That doesn't work on some Windows. <5> kjetilho: float('inf'), I mean. <5> Also not on some Mac, IIRC. <0> i might do try: inf = float('inf') except: inf = 1e200*1e200 <8> mcferrill|away: i was just saying that i think for things like that, maybe you can just initialize what you were going to initialize to "infinity" to just be the first thing you see before starting a loop, unless that just doesn't work here <8> but anyway, i'm sure just defaulting to a maximum value isn't a problem.. it seems to me that you (or someone) thinks it is <0> Vratha: the question is, what is the maximum value? <5> Also, Python special cases infinity in marshal code to ensure round tripping, even when underlying C library doesn't do that, I think. <8> i don't know; doesn't python have something akin to C++'s numerical limits or C's limits.h file? <10> Greetings, oh people of #python! <5> (If it didn't do that, running .py and .pyc may show different output!) <5> zooko: Greeting! <1> Vratha_: the limit to how big a number can get is based on the amount of memory python can address. <5> zooko: Are you happened to be the author of Mnet? <8> Jerub: ok, well is there a python module that determines this number? <11> hello! <11> how can i invert a regular expressions ? <5> Vratha_: There's sys.maxint <1> Vratha_: there's a little problem with that <1> sanxiyn: which is irrelevent. <5> yes <11> like ...i have a string full o' crap..i wanna extract some information from it...i wanna 'clear out the rest of the matched part' <1> Vratha_: see, to get that number, you would have to use all the memory that python can use. <1> Vratha_: are you seeing the problem yet? <8> python doesn't know how much memory it has available to it when it's compiled? <1> Vratha_: ... <1> Vratha_: no, you're not seeing the problem. <1> Vratha_: Picture being in the room with a man. <8> does python increase number size dynamically?
<5> Vratha_: Yes, unlike Java, Python doesn't have -Xms option. <1> Vratha_: that man can write down the answer to any calculation. <8> er.. "register size" dynamically? <9> You can't represent the largest possibly number that can fit in memory without actually using that much memory. <1> Vratha_: he's got 100 sheets of paper. <1> Imagine that you ask him, "before we begin, can you write down the largest number you can write down, before you run out of paper" <8> Jerub: anyway, i imagine python adds more memory as it needs it to make more room for larger numbers... i don't need your analogy <5> Jerub: In some environments, program is given fixed amount of memory, which program can determine without using them all. <8> so yes, i see the problem <1> Vratha_: Then, after he has done this, how much paper is left? <5> Jerub: As in "heap size" execution argument. <7> cadu: not sure what you're asking, please restate with an example <1> Vratha_: now equate those 100 pages to 4 gigabytes. <8> ... <8> jesus <5> Jerub: Oh please stop. <1> yay :) <5> Jerub: If Java program is given -Xmx4m, it knows it has 4m without using them all. <5> Which doesn't apply to Python, btw. <9> Unless you're using gcj. <9> gij, rather. <1> sanxiyn: yes, but you can't return a BigNumber that contains the exact number very efficiently, can you. <1> you only know its order of magnitute. <9> gij doesn't have -Xm* either. <8> you know, saying "python dynamically increases memory used to accomodate larger numbers" is easier than your story... especially considering that i already know the concept just didn't know that python applied that concept <1> er magnitude, and can only represent it with a float, not a long. <11> no regular expression ubergods down here? :( <0> Jerub: the bignumber itself doesn't matter, we just need an upper bound on it ;) <1> wow, he got irritated. <8> yes, by a stupid story <1> I was only trying to illustrate what I meant by "limited by the maxium memory the process can address" <8> because that's really basic stuff that was being played out into some dramatic story <9> If it's basic then how come you didn't get it in the first place? <1> ;) <1> See, you understand fully now. <12> hey all, is there a way to indent multiline strings in source without altering their content ? <0> sm: i don't believe so <8> ignacio: i did; i just didn't know that python used a dynamic amount of memory for numerical length, whereas C uses a fixed size... that's not the same as "not getting it" <0> conversation is over, please move on ;) i didn't intend my simple question to result in a flamewar :) <9> "Jerub: Vratha_: the limit to how big a number can get is based on the amount of memory python can address." <12> hmm, I'll try this http://python.org/doc/2.4.2/ref/string-catenation.html <12> thx <8> ignacio: cool <6> sm: yeah <12> leo is having conniptions with my unit tests' raw strings <12> anyone out there using leo for development ? <6> you can use \ to break the line up and you don't even have to use + to concatonate the strings because python takes newline to be concatonation with literal strings. also you don't have to use \ if your string is inside of ()'s <9> Multiline strings don't need \ to supress newlines. That's why they're called "multiline". <7> hmm, there should be a utility function to de-indent a multiline string. i.e.: look at second line, remove that amount of indentation from all lines <7> but it would need to be in str to be really useful. <13> hmm, does python have anything similar to php.net/function_name ? <13> (i.e. online reference <0> pydoc functionname, or http://python.org/doc/2.4.2/lib/lib.html <14> kjetilho: s = '\n'.join([x[:4] for x in s.split('\n')]) ? <14> kjetilho: that's how I do it <7> mcferrill: well that hardcodes an indent of 4, I'd like to be able to say just """long text""".deindent() <14> kjetilho: s.strip() <14> kjetilho: that clears all whitespace from beginning and end of "s"... <7> not for every line <14> kjetilho: just run that over every line: s = '\n'.join([x.strip() for x in s.split('\n')]) <7> but it still isn't what I like, since it will remove internal indentation in the long text <6> deindent() would be convenient <15> kjetilho, then you'll have to use a regexp <15> mcferrill, you'd have to use os.linesep instead of '\n' to make it portable :) <7> Yango: you can find the indent level with len(line) - len(line.lstrip()) <15> kjetilho, true <7> mcferrill: the point is that it has to be so convenient that it is used instead of ("line1\n" <newline-and-indent> "line2\n" <newline-and-indent> "line3\n") in my code. <12> yes, the latter is a bit hard to read and cut/paste <12> though it does keep leo happy <12> I think I will bite the bullet and write \n 's all on one long line <12> bah <13> hmm, anyone know why I'm getting "Invalid syntax" in the following line?
Return to
#python or Go to some related
logs:
fpd2185 ubuntu gtk webcore gentoo totem-video-thu fluxbox_generate-menu ubuntu fedoracore6 resume reload profile.env #lisp KERİM SAY #lisp xvnc the server does not accept new connections
|
|