| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Comments:
<0> Cope: please don't paste more than 3 lines to the channel. <1> tirkal: that was three lines <0> Cope: yup, but not the upper part. <1> oh right, yeah sorry <2> robin_2: well, in fact char * _are_ LPCTSTR <3> innervision: or wchar if the build is UNICODE <2> robin_2: yeap, and there you have to choose. <3> innervision: is it some setting in swig so it uses wchar ? <3> because I can't find it. <2> robin_2: mhh, as far as I remember (long time since last time I used SWIG) there were some configuration files... <1> so what I am trying to do is, from a file containing 100s of lines, do a re match, and then pick out fields; <1> the re match works, as i can print out the correct lines <1> (with the , after the print) <1> but my split() fails on intermediate lines, I think <4> I am writing an application which will divide big numbers and it works rather slow...would it be faster if I write a C module to divide big numbers or is there another way maybe? <5> hawking: C doesn't have "big numbers", so you would need a big numbers library.
<1> oh maybe I am worng... sorry, I think I've just fat fingered the [20] <1> :( <2> hawking: what do you mean by "big numbers"? <1> *blush* <4> Erwin I know <4> innervision numbers more than 500 digits <6> i'm a fan of the "buy more expensive hardware" solution :) <4> Erwin I just have to know if that will make it faster or if the builtin divide is already developed with C <5> "builtin divide" ? <5> dividing a python long by another long uses C code. <5> >>> print 13**37/4**42 <5> 8499324282253148 <5> ^^ instant answer <2> hawking: well, AFAIK all big numbers libraries for C are made in C (or ***embly) <3> innervision: "At this time, SWIG does not provide any special support for Unicode or wide-character strings (the C wchar_t type). " <3> from the SWIG docs <3> ;( <5> Generally to make things fast in Python you need to spend as little time in Python as possible. <2> robin_2: ****s to use swig :( <3> innervision: any alternative ? <3> ctypes was no success either <2> robin_2: maybe use ctypes? <4> Erwin : how exactly would I do that? <2> robin_2: oh :( <5> hawking: By programming smartly. <4> innervision : do you mean big number libs for python? <4> Erwin : yeah I guess that's the best option <2> hawking: all of them <5> hawking: Did you profile your program? <4> Erwin no <5> hawking: Then it is rather prematurely to be thinking of rewriting it in C <4> Erwin : well it's a simple app <4> just needs to run fast <7> hawking: 1) profile. 2) redesign your algorithm 3) GNU MP if absolutely necessary <2> hawking: now I understood, you think that dividing the numbers in C rather than in python will make things faster? well, I don't think it will make such a big difference. <7> hawking: having no idea what your algorithm is I would suggest you look at divmod. It would be a big difference, if applicable :) <4> divmod what's that? <7> err wait, I'm thinking about something else. Nevermind! <5> divmod(a,b) returns a/b and a%b faster than a/b and a%b <7> but divmod is a combined divide and modular <5> But really, you cannot hope for a silver bullet <5> If you refuse to analyse and profile your algorithm, you have already lost. <7> For all you know it may be the print that's slow ;) <4> Erwin : I see .. does it work with long numbers too? <5> It is very slow to convert large longs to strings. <4> I know that <7> int, long, float.. probably others <1> pattern = re.compile(r"*(*)$") <5> Cope: Err, that's a nonsensical pattern. <1> yes <1> utterly <1> i was about to explain what it was tryig to do <1> If I have a line like "some stuff like this example(10)" <1> I only want the (10) <1> actually I only want the 10 <5> >>> m = re.search(r"\((\d+)\)", "example(10)"); print m.group(1) <5> 10 <5> That's ***uming your () can only contain digits. <1> yeah <1> that's correct <5> If you want everything until the first ) you can use .*? there instead, for a non-greedy match everything (i.e. match the least amount possible)
<4> how can i get divmod for python? <8> At divmod.org? <5> hawking: The same place you got "abs" for Python. <4> veracon_ well there are many packages there which one do i need to use divmod to divide numbers faster <2> Erwin: you get "abs" the same place you get "pecs" and "biceps"? <8> Oh <9> hawking: divmod(x, y) is a built-in function in python <5> hawking: divmod doesn't divide numbers faster. divmod is faster than a division AND a mod. <10> very cunning innervision <4> lol sorry <2> Flibberdy: lol <5> Really, you are looking for some magic bullet when none exists. <8> 'from abs import sixpack'? ;P <4> Erwin : I just need mod actually <9> veracon_: its early here. oops :P <8> Hehe. <11> i think that function could be more general... 'from abs import pack; pack(6)' <11> or, more realistically, pack(1) <12> Is it possible to use call C libraries from a python programme? Where can I read about it? <12> s/use call/call/ <2> tralala: look for ctypes and SWIG <5> tralala: Or pyrex. <2> Erwin: had they ever ported Pyrex to windows? <12> thank you! <5> innervision: I'm not sure it would require porting. It just generates C code and is written in pure Python. <2> Erwin: mhh, maybe I'm wrong but last time I checked it didn't work very well with any C compiler under window (not even GCC) <11> as long as that's being talked about... what is there for embedding python in C?that's a project i'm gonna have to tackle in a couple weeks. i have experience with the direct C API but obviously something a bit more automatic would be nice <5> mcmillen: You would build a Python module using the above mentioned tools to interface with your code really. That's all. <5> mcmillen: If you have some C API you want your Python code to access , you must wrap it, whether you embed or extend <11> i need to embed (for very baroque reasons). from what i see, pyrex won't help me, but swig might? <5> pyrex will help you just as much as swig <5> they both let you wrap C APIs for use from Python. <5> The trick in embedding is to do as much in Python as possible. E.g. setup code, interpreters etc. <13> COM! <11> *nods* okay, pyrex's documentation seems more accurate than their "brief description", which led me to believe it couldn't be used for embedding... thanks for pointing it out <11> and yes, i definitely want to do as much as possible in python <11> but unfortunately the executable itself has to be C <5> Why? <11> the python bit is one component of a proprietary, closed-source distributed message-p***ing framework... think a crippled version of CORBA <11> and if i don't use the existing (closed-source) tools for developing linux executables that talk to this thing... well, i'd have to reverse-engineer the format of the TCP connections between these executables... which is not really my cup of tea <14> hi, i am very new to python, just started it. how can i put string with an integer? hwo do i convert an integer to a string?? <5> draxas: What tutorial are you using? <8> You can use the str and int cl***es <14> nothign really :) <8> str(2) = '2' <14> just started by guessing :) <8> int('33') = 33 <5> draxas: Start reading one then. <8> Yeah, good idea. <14> l;ets say i have somenum = 15 and then i do print "Hello, The ID is " , hwo do i add sumenum there, + doesnt seem to work <8> print 'Hello, the ID is %s' % somenum <14> very noobish question, i know :) <8> That's how I would do it <14> thanks veracon_ <14> works smooth <8> Remember, if you're formatting with multiple arguments, you must use a longer sequence (list, tuple -- or dictionary if you use named arguments) but if you're just beginning, let's wait with that. :P <14> im not new to programming, so far i do pascal, delphi and php ): <8> If you want a tutorial, I recommend Dive Into Python (diveintopython.org), that's how I started <2> draxas: what veracon_ means is that if you need to put some more things inside the string you could use "This is an string with (%s) or (%s) arguments" % (arg1, arg2) <14> ok ill have a look <14> allright innervision <8> Yeah <8> And named arguments could work like this; 'This is a %(what).' % {'what': 'string'} <8> no <8> %(what)s* <14> just one question, is python to be used more on web servers, or for actual software? there are some websites that use python and some python based software.. <8> I find it pretty good for both purposes, personally <5> Python is a general-purpose high-level programming language <14> ok :) <14> i figured out first code in 30 seconds, for c it took fo me to ask in irc <2> draxas: I have used python to build a GPS data gathering server, as well as the GPS client... and with the right framework it works very well on the web too <14> great stuff!:) <8> Yeah, there are some really great frameworks.
Return to
#python or Go to some related
logs:
selinux firewall stopped martian source crash #math zabor.org jrpg/ #perl defult for raw_input Could not use perl thread modules sql get unique results #linux #linux
|
|