Quick question about threads and interpreters.

2011-07-31 Thread Ira Gray
Lets say I have a program that is running a python interpreter in the main
thread.

I come along, write a .DLL and throw it into the program. My .dll has its
own thread (right?), separate from the main thread, and then makes a
pyrun_simplestring call to the pythonxx.dll. The pyrun_simplestring call
attempts to make contact with a function in the original python program. In
short, I'm attempting to leverage existing functionality in the original
python program from my .DLL.
I'm sure that sounds confusing, so maybe: PythonInterpreter_MainThread is
running some SourceCode, MyDLL_PyRun_SimpleString_OtherThread makes call(?)
to the same SourceCode.

Now, my question is: What happens? Is another python interpreter instance
created in my .dll thread to handle that call? is my call 'separate' from
the main thread interpreter? I'm hoping someone can point me towards some
material to better understand what might happen if I did what I outlined
above. It's a small school project (not homework, just a hey, remember when
I asked you about blahblah, well I got it working!) and I'd appreciate any
guidance I could get into the dark arts of multiple threads and how they
relate to python interpreters, and if multiple python interpreters are
created (one for each thread) how making calls to the same code works.

Thank you for your time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Book Recomendations

2008-03-01 Thread Ira Solomon
I am an experienced programmer (40 years).  I've done Algol (if you've
heard of that you must be old too), PL/1, VB,VBA, a little C, and a
few other odd languages (e.g. Taskmate).
I'm interested in learning Python and have downloaded a slew of books.
Too many.
I'd like a recommendation as to which books are considered to be the
cream of the crop.
I know there are tutorials on the web, but, again, I don't know the
quality.  I would appreciate recommendations on those as well.

Thanks

Ira
-- 
http://mail.python.org/mailman/listinfo/python-list


Sorting Large File (Code/Performance)

2008-01-24 Thread Ira . Kovac
Hello all,

I have an Unicode text file with 1.6 billon lines (~2GB) that I'd like
to sort based on first two characters.

I'd greatly appreciate if someone can post sample code that can help
me do this.

Also, any ideas on approximately how long is the sort process going to
take (XP, Dual Core 2.0GHz w/2GB RAM).

Cheers,

Ira

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting Large File (Code/Performance)

2008-01-24 Thread Ira . Kovac
Thanks to all who replied. It's very appreciated.

Yes, I had to doublecheck line counts and the number of lines is ~16
million (insetead of stated 1.6B).

Also:

What is a Unicode text file? How is it encoded: utf8, utf16, utf16le, 
utf16be, ??? If you don't know, do this:
The file is UTF-8

 Do the first two characters always belong to the ASCII subset?
Yes, first two always belong to ASCII subset

 What are you going to do with it after it's sorted?
I need to isolate all lines that start with two characters (zz to be
particular)

 Here's a start: http://docs.python.org/lib/typesseq-mutable.html
 Google GnuWin32 and see if their sort does what you want.
Will do, thanks for the tip.

 If you really have a 2GB file and only 2GB of RAM, I suggest that you don't 
 hold your breath.
I am limited with resources. Unfortunately.

Cheers,

Ira
-- 
http://mail.python.org/mailman/listinfo/python-list


Filtering content of a text file

2007-07-27 Thread Ira . Kovac
Hello All,

I'd greatly appreciate if you can take a look at the task I need help
with.

It'd be outstanding if someone can provide some sample Python code.

Thanks a lot,

Ira

---
Problem
---

I am working with 30K+ record datasets in flat file format (.txt) that
look like this:

//-+alibaba sinage
//-+amra damian//_9
//-+anix anire//_
//-+borom
//-+bokima sun drane
//-+ciren
//-+cop calestieon eded
//-+ciciban
//-+drago kimano sole


The records start with the same string (in the example //-+) wich is
followed by another string of characters taht's changing from record
to record.

I am working on one file at the time and for each file I need to be
able to do the following:

a) By looping thru the file the program should isolate all records
that have letter a following the //-+
b) The isolated dataset will contain only records that start with //-
+a
c) Save the isolated dataset as flat flat text file named a.txt
d) Repeat a), b) and c) for all letters of english alphabet (a thru z)
and numerical values (0 thru 9)






CP: An inch of time is an inch of gold but you can't buy that inch of
time with an inch of gold.

Random Link Generator
--
http://www.transactioncodes.com
--

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Filtering content of a text file

2007-07-27 Thread Ira . Kovac
Thanks all for the input. This is going to be a great basis for
starting. And, yeah - I wish it was a homework.

Best,

Ira

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing interpreter's deafult output/error streams

2005-08-01 Thread Ira
OK let me rephrase,

the standard error stream (and if I'm not mistaken also the one that
PyErr_Print() writes to) is the python object sys.stderr. Now say I'd go
ahead and write the following in python...

SomeNewStreamOrFileOrWhateverItIs = new stream
sys.stderr = SomeNewStreamOrFileOrWhateverItIs

I can go ahead and do the exact same thing from the C source code. All I
need to do is to figure out how to wrap a c-style FILE* with a PyObject, And
PySys_SetObjet(stderr, newstream);

I'm very new to python so that might be nonsense but it appeals to my
programmer's common sense. Can anyone tell me how to do this?


Michael Hudson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Ira [EMAIL PROTECTED] writes:

  Using an embedded interpreter, how do I change it's default output
  streams (specifically the one used by PyErr_Print() which I'm
  guessing is the default error stream)?

 It looks as though it writes to stderr unconditionally.  But most of
 the reasons for ended up in PyErr_Print can be intercepted at a higher
 level (I think -- I mean sys.excepthook  co here).

 Cheers,
 mwh

 -- 
   ARTHUR:  Yes.  It was on display in the bottom of a locked filing
cabinet stuck in a disused lavatory with a sign on the door
saying Beware of the Leopard.
 -- The Hitch-Hikers Guide to the Galaxy, Episode 1
 -- 
 http://mail.python.org/mailman/listinfo/python-list




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing interpreter's deafult output/error streams

2005-08-01 Thread Ira
OK let me rephrase,

the standard error stream (and if I'm not mistaken also the one that
PyErr_Print() writes to) is the python object sys.stderr. Now say I'd go
ahead and write the following in python...

SomeNewStreamOrFileOrWhateverItIs = new stream
sys.stderr = SomeNewStreamOrFileOrWhateverItIs

I can go ahead and do the exact same thing from the C source code. All I
need to do is to figure out how to wrap a c-style FILE* with a PyObject, And
PySys_SetObjet(stderr, newstream);

I'm very new to python so that might be nonsense but it appeals to my
programmer's common sense. Can anyone tell me how to do this?


Michael Hudson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Ira [EMAIL PROTECTED] writes:

  Using an embedded interpreter, how do I change it's default output
  streams (specifically the one used by PyErr_Print() which I'm
  guessing is the default error stream)?

 It looks as though it writes to stderr unconditionally.  But most of
 the reasons for ended up in PyErr_Print can be intercepted at a higher
 level (I think -- I mean sys.excepthook  co here).

 Cheers,
 mwh

 -- 
   ARTHUR:  Yes.  It was on display in the bottom of a locked filing
cabinet stuck in a disused lavatory with a sign on the door
saying Beware of the Leopard.
 -- The Hitch-Hikers Guide to the Galaxy, Episode 1
 -- 
 http://mail.python.org/mailman/listinfo/python-list





-- 
http://mail.python.org/mailman/listinfo/python-list


Changing interpreter's deafult output/error streams

2005-07-31 Thread Ira
Hi,

Using an embedded interpreter, how do I change it's default output streams
(specifically the one used by PyErr_Print() which I'm guessing is the
default error stream)?

Cheers,
Ira



-- 
http://mail.python.org/mailman/listinfo/python-list