How to write list of integers to file with struct.pack_into?

2023-10-03 Thread Jen Kris via Python-list
My previous message just went up -- sorry for the mangled formatting.  Here it is properly formatted: I want to write a list of 64-bit integers to a binary file.  Every example I have seen in my research converts it to .txt, but I want it in binary.  I wrote this code, based on some earlier wor

Re: How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Jen Kris via Python-list
once.  Thanks for your help.  Oct 2, 2023, 17:47 by die...@handshake.de: > Jen Kris wrote at 2023-10-2 00:04 +0200: > >Iwant to write a list of 64-bit integers to a binary file. Everyexample I > >have seen in my research convertsit to .txt, but I want it in binary. I >

Re: How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Jen Kris via Python-list
the extra overhead, and it's more difficult yet if I'm using the Python integer output in a C program.  Your solution solves those problems.  Oct 2, 2023, 17:11 by python-list@python.org: > On 2023-10-01 23:04, Jen Kris via Python-list wrote: > >> >> Iwant to write

How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Jen Kris via Python-list
Iwant to write a list of 64-bit integers to a binary file. Everyexample I have seen in my research convertsit to .txt, but I want it in binary. I wrote this code,based on some earlier work I have done: buf= bytes((len(qs_array)) * 8) foroffset in range(len(qs_array)): item_to_write= byt

Re: How does a method of a subclass become a method of the base class?

2023-03-27 Thread Jen Kris via Python-list
Thanks to everyone who answered this question.  Your answers have helped a lot.  Jen Mar 27, 2023, 14:12 by m...@wichmann.us: > On 3/26/23 17:53, Jen Kris via Python-list wrote: > >> I’m asking all these question because I have worked in a procedural style >> for many

Re: How does a method of a subclass become a method of the base class?

2023-03-26 Thread Jen Kris via Python-list
now I’m studying classes in more depth. The three answers I have received today, including yours, have helped a lot.  Thanks very much.  Jen Mar 26, 2023, 22:45 by c...@cskk.id.au: > On 26Mar2023 22:36, Jen Kris wrote: > >> At the final line it calls "satisfy"

Re: How does a method of a subclass become a method of the base class?

2023-03-26 Thread Jen Kris via Python-list
the choose_method in the UrnaryConstraint class because of "super(BinaryConstraint, self).__init__(strength)" in step 2 above?  Thanks for helping me clarify that.  Jen Mar 26, 2023, 18:55 by hjp-pyt...@hjp.at: > On 2023-03-26 19:43:44 +0200, Jen Kris via Python-list wrote: &g

Re: How does a method of a subclass become a method of the base class?

2023-03-26 Thread Jen Kris via Python-list
Thanks to Richard Damon and Peter Holzer for your replies.  I'm working through the call chain to understand better so I can post a followup question if needed.  Thanks again. Jen Mar 26, 2023, 19:21 by rich...@damon-family.org: > On 3/26/23 1:43 PM, Jen Kris via Python-li

How does a method of a subclass become a method of the base class?

2023-03-26 Thread Jen Kris via Python-list
The base class: class Constraint(object): def __init__(self, strength):     super(Constraint, self).__init__()     self.strength = strength def satisfy(self, mark):     global planner     self.choose_method(mark) The subclass: class UrnaryConstraint(Constraint): def __init__

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
I wrote my previous message before reading this.  Thank you for the test you ran -- it answers the question of performance.  You show that re.finditer is 30x faster, so that certainly recommends that over a simple loop, which introduces looping overhead.  Feb 28, 2023, 05:44 by li...@tompass

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
Using str.startswith is a cool idea in this case.  But is it better than regex for performance or reliability?  Regex syntax is not a model of simplicity, but in my simple case it's not too difficult.  Feb 27, 2023, 18:52 by li...@tompassin.net: > On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com

RE: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
hings that are far from the same such as matching two > repeated words of any kind in any case including "and and" and "so so" or > finding words that have multiple doubled letter as in the stereotypical > bookkeeper. In those cases, you may want even more than offset

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
(match.start(), match.end()) 4 18 26 40 I don't insist on terseness for its own sake, but it's cleaner this way.  Jen Feb 27, 2023, 16:55 by c...@cskk.id.au: > On 28Feb2023 01:13, Jen Kris wrote: > >> I went to the re module because the specified string may appear mo

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
string.count() only tells me there are N instances of the string; it does not say where they begin and end, as does re.finditer.  Feb 27, 2023, 16:20 by bobmellow...@gmail.com: > Would string.count() work for you then? > > On Mon, Feb 27, 2023 at 5:16 PM Jen Kris via Python-list <

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
e first instance, but not the second one.  The re code finds both instances.  If I knew that the substring occurred only once then the str.find would be best.  I changed my re code after MRAB's comment, it now works.  Thanks much.  Jen Feb 27, 2023, 15:56 by c...@cskk.id.au: > On

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
Yes, that's it.  I don't know how long it would have taken to find that detail with research through the voluminous re documentation.  Thanks very much.  Feb 27, 2023, 15:47 by pyt...@mrabarnett.plus.com: > On 2023-02-27 23:11, Jen Kris via Python-list wrote: > >>

How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
When matching a string against a longer string, where both strings have spaces in them, we need to escape the spaces.  This works (no spaces): import re example = 'abcdefabcdefabcdefg' find_string = "abc" for match in re.finditer(find_string, example):     print(match.start(), match.end()) Tha

Re: To clarify how Python handles two equal objects

2023-01-14 Thread Jen Kris via Python-list
Yes, in fact I asked my original question – "I discovered something about Python array handling that I would like to clarify" -- because I saw that Python did it that way.  Jan 14, 2023, 15:51 by ros...@gmail.com: > On Sun, 15 Jan 2023 at 10:32, Jen Kris via Python-list >

RE: To clarify how Python handles two equal objects

2023-01-14 Thread Jen Kris via Python-list
a) > 3 > sys.getrefcount(b) > 3 > c = b > d = a > sys.getrefcount(a) > 5 > sys.getrefcount(d) > 5 > del(a) > sys.getrefcount(d) > 4 > b = "something else" > sys.getrefcount(d) > 3 > > So, in theory, you could carefully write your code to C

Re: To clarify how Python handles two equal objects

2023-01-13 Thread Jen Kris via Python-list
34 >   >>> b=1234 >   >>> a is b >   False > > Not sure what happens if you manipulate the data referenced by 'b' in the > first example thinking you are changing something referred to by 'a' ... but > you might be smart to NOT th

RE: To clarify how Python handles two equal objects

2023-01-13 Thread Jen Kris via Python-list
other data > structure. Of course, if anything else is accessing the result in the > original in between, it won't work. > > Just FYI, a similar analysis applies to uses of the numpy and pandas and > other modules if you get some kind of object holding indices to a series s

Re: To clarify how Python handles two equal objects

2023-01-11 Thread Jen Kris via Python-list
e precise, an operation on one name will be reflected in the other name.  The difference is in the names,  not the pointers.  Each name has the same pointer in my example, but operations can be done in Python using either name.  Jan 11, 2023, 09:13 by r...@roelschroeven.net: > Op 11/01/2

Re: To clarify how Python handles two equal objects

2023-01-11 Thread Jen Kris via Python-list
ct (memory block) so I have to be aware of that when handing this kind of situation.  Jan 10, 2023, 17:31 by greg.ew...@canterbury.ac.nz: > On 11/01/23 11:21 am, Jen Kris wrote: > >> where one object derives from another object (a = b[0], for example), any >> operation tha

Re: To clarify how Python handles two equal objects

2023-01-10 Thread Jen Kris via Python-list
matrix operations, you might use NumPy. Its > arrays and matrices are heavily optimized for fast processing and provide > many useful operations on them. No use calling out to C code yourself when > NumPy has been refining that for many years. > > On 1/10/2023 4:10 PM

Re: To clarify how Python handles two equal objects

2023-01-10 Thread Jen Kris via Python-list
> On Wed, 11 Jan 2023 at 07:14, Jen Kris via Python-list > wrote: > >> >> I am writing a spot speedup in assembly language for a short but >> computation-intensive Python loop, and I discovered something about Python >> array handling that I would like to clarify.

To clarify how Python handles two equal objects

2023-01-10 Thread Jen Kris via Python-list
I am writing a spot speedup in assembly language for a short but computation-intensive Python loop, and I discovered something about Python array handling that I would like to clarify.  For a simplified example, I created a matrix mx1 and assigned the array arr1 to the third row of the matrix:

Re: Debugging Python C extensions with GDB

2022-11-14 Thread Jen Kris via Python-list
Thanks for your reply.  Victor's article didn't mention ctypes extensions, so I wanted to post a question before I build from source.  Nov 14, 2022, 14:32 by ba...@barrys-emacs.org: > > >> On 14 Nov 2022, at 19:10, Jen Kris via Python-list >> wrote: >> >

Debugging Python C extensions with GDB

2022-11-14 Thread Jen Kris via Python-list
In September 2021, Victor Stinner wrote “Debugging Python C extensions with GDB” (https://developers.redhat.com/articles/2021/09/08/debugging-python-c-extensions-gdb#getting_started_with_python_3_9).   My question is:  with Python 3.9+, can I debug into a C extension written in pure C and call

Re: PyObject_CallFunctionObjArgs segfaults

2022-09-30 Thread Jen Kris via Python-list
That's great.  It clarifies things a lot for me, particularly re ref count for new references.  I would have had trouble if I didn't decref it twice.  Thanks very much once again.  Sep 30, 2022, 12:18 by pyt...@mrabarnett.plus.com: > On 2022-09-30 17:02, Jen Kris wrote: > &

Re: PyObject_CallFunctionObjArgs segfaults

2022-09-30 Thread Jen Kris via Python-list
ndom == 0x0){     PyErr_Print(); Leaks here because of the refcount Assuming pMod_random is not null, why would this leak?  Thanks again for your input on this question.  Jen Sep 29, 2022, 17:33 by pyt...@mrabarnett.plus.com: > On 2022-09-30 01:02, MRAB wrote: > >> On 2022-09-

Re: PyObject_CallFunctionObjArgs segfaults

2022-09-29 Thread Jen Kris via Python-list
anks again to MRAB for helpful comments.  Jen Sep 29, 2022, 15:31 by pyt...@mrabarnett.plus.com: > On 2022-09-29 21:47, Jen Kris wrote: > >> To update my previous email, I found the problem, but I have a new problem. >> >> Previously I cast PyObject * value_ptr = (PyOb

Re: PyObject_CallFunctionObjArgs segfaults

2022-09-29 Thread Jen Kris via Python-list
> > So I incremented the reference to all objects in Get_LibModules, but I still > get the same segfault at PyObject_CallFunctionObjArgs.  Unfortunately, > reference counting is not well documented so I’m not clear what’s wrong.  > > > > > Sep 29, 2022, 10:06 by p

Re: PyObject_CallFunctionObjArgs segfaults

2022-09-29 Thread Jen Kris via Python-list
cremented the reference to all objects in Get_LibModules, but I still get the same segfault at PyObject_CallFunctionObjArgs.  Unfortunately, reference counting is not well documented so I’m not clear what’s wrong.  Sep 29, 2022, 10:06 by pyt...@mrabarnett.plus.com: > On 2022-09-29 16:5

PyObject_CallFunctionObjArgs segfaults

2022-09-29 Thread Jen Kris via Python-list
Recently I completed a project where I used PyObject_CallFunctionObjArgs extensively with the NLTK library from a program written in NASM, with no problems.  Now I am on a new project where I call the Python random library.  I use the same setup as before, but I am getting a segfault with random

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
e uses the append method.  But my PyList_Append is not doing the job so that's where I'm looking now.  Thanks very much for your reply. Mar 12, 2022, 15:36 by ros...@gmail.com: > On Sun, 13 Mar 2022 at 10:30, Jen Kris wrote: > >> >> >> Chris, you were right t

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
-- hence pDictData is empty.  I tried with PyList_SetItem but that doesn't work.  Do you know of way to "extend" a list in the C API.  Thanks very much.  Jen Mar 12, 2022, 13:57 by ros...@gmail.com: > On Sun, 13 Mar 2022 at 08:54, Jen Kris wrote: > >> >> >

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
pDictData, despite the name, is a list of 2-tuples where each 2-tuple is a dictionary object and a string.  Mar 12, 2022, 13:41 by ros...@gmail.com: > On Sun, 13 Mar 2022 at 08:25, Jen Kris via Python-list > wrote: > >> PyObject* slice = PySlice_New(PyLong_FromLong(0)

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
s.com: > On 2022-03-12 21:24, Jen Kris via Python-list wrote: > >> I have a C API project where I have to slice a list into two parts.   >> Unfortunately the documentation on the slice objects is not clear enough for >> me to understand how to do this, and I haven’t found e

Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
I have a C API project where I have to slice a list into two parts.   Unfortunately the documentation on the slice objects is not clear enough for me to understand how to do this, and I haven’t found enough useful info through research.  The list contains tuple records where each tuple consists

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Jen Kris via Python-list
(this is the REPR of pWTok): "['[', 'Emma', 'by', 'Jane', 'Austen', '1816', ']']" Thanks again to both of you.  Jen Mar 7, 2022, 11:03 by pyt...@mrabarnett.plus.com: > On 2022-03-07 17:05, Jen Kris wrote: >

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Jen Kris via Python-list
The PyObject str_sentence is a string representation of a list.  I need to convert the list to a string like "".join because that's what the library call takes.  Mar 7, 2022, 09:09 by ros...@gmail.com: > On Tue, 8 Mar 2022 at 04:06, Jen Kris via Python-list > wrote: &g

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Jen Kris via Python-list
the same way as ‘’.join, and if not then (2) how can I strip characters from a string object in the C API?  Thanks. Mar 6, 2022, 17:42 by pyt...@mrabarnett.plus.com: > On 2022-03-07 00:32, Jen Kris via Python-list wrote: > >> I am using the C API in Python 3.8 with the nltk

C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-06 Thread Jen Kris via Python-list
I am using the C API in Python 3.8 with the nltk library, and I have a problem with the return from a library call implemented with PyObject_CallFunctionObjArgs.  This is the relevant Python code: import nltk from nltk.corpus import gutenberg fileids = gutenberg.fileids() sentences = gutenberg

Re: C API - How to return a Dictionary as a Dictionary type

2022-02-14 Thread Jen Kris via Python-list
Yes, that works.  This is my first day with C API dictionaries.  Now that you've explained it, it makes perfect sense.  Thanks much.  Jen Feb 14, 2022, 17:24 by ros...@gmail.com: > On Tue, 15 Feb 2022 at 12:07, Jen Kris via Python-list > wrote: > >> >> I created a

C API - How to return a Dictionary as a Dictionary type

2022-02-14 Thread Jen Kris via Python-list
I created a dictionary with the Python C API and assigned two keys and values: PyObject* this_dict = PyDict_New();  const char *key = "key1"; char *val = "data_01";  PyObject* val_p = PyUnicode_FromString(val);  int r = PyDict_SetItemString(this_dict, key, val_p);  // Add another k-v pair key = "

Re: C API PyObject_Call segfaults with string

2022-02-10 Thread Jen Kris via Python-list
Thank you for that suggestion.  It allowed me to replace six lines of code with one.  :) Feb 10, 2022, 12:43 by pyt...@mrabarnett.plus.com: > On 2022-02-10 20:00, Jen Kris via Python-list wrote: > >> With the help of PyErr_Print() I have it solved.  Here is the final code

Re: C API PyObject_Call segfaults with string

2022-02-10 Thread Jen Kris via Python-list
erday.  Thanks much for your help. Jen Feb 9, 2022, 18:43 by pyt...@mrabarnett.plus.com: > On 2022-02-10 01:37, Jen Kris via Python-list wrote: > >> I'm using Python 3.8 so I tried your second choice: >> >> pSents = PyObject_CallFunctionObjArgs(pSentMod, pListItem); >

Re: C API PyObject_Call segfaults with string

2022-02-10 Thread Jen Kris via Python-list
om PyErr_Print.  I'm not far enough along in my C_API work to understand why, but it doesn't work.  Thanks very much for your help on this.  Jen Feb 9, 2022, 17:40 by songofaca...@gmail.com: > On Thu, Feb 10, 2022 at 10:37 AM Jen Kris wrote: > >> >> I

Re: C API PyObject_Call segfaults with string

2022-02-09 Thread Jen Kris via Python-list
I'll do that and post back tomorrow.  The office is closing and I have to leave now (I'm in Seattle).  Thanks again for your help.  Feb 9, 2022, 17:40 by songofaca...@gmail.com: > On Thu, Feb 10, 2022 at 10:37 AM Jen Kris wrote: > >> >> I'm using Python

Re: C API PyObject_Call segfaults with string

2022-02-09 Thread Jen Kris via Python-list
. Can be > used with Python <3.9 too. > pSents = PyObject_CallFunctionObjArgs(pSentMod, pListItem); > > On Thu, Feb 10, 2022 at 10:15 AM Jen Kris wrote: > >> >> Right you are. In that case should I use Py_BuildValue and convert to tuple >> (because it won'

Re: C API PyObject_Call segfaults with string

2022-02-09 Thread Jen Kris via Python-list
Right you are.  In that case should I use Py_BuildValue and convert to tuple (because it won't return a tuple for a one-arg), or should I just convert pListStr to tuple?  Thanks for your help.  Feb 9, 2022, 17:08 by songofaca...@gmail.com: > On Thu, Feb 10, 2022 at 10:05 AM Jen Kri

Re: C API PyObject_Call segfaults with string

2022-02-09 Thread Jen Kris via Python-list
/vrut/python/ext/buildValue.html, PyBuildValue "builds a tuple only if its format string contains two or more format units" and that doc contains examples.  Feb 9, 2022, 16:52 by songofaca...@gmail.com: > On Thu, Feb 10, 2022 at 9:42 AM Jen Kris via Python-list > wrote: >

C API PyObject_Call segfaults with string

2022-02-09 Thread Jen Kris via Python-list
This is a follow-on to a question I asked yesterday, which was answered by MRAB.   I'm using the Python C API to load the Gutenberg corpus from the nltk library and iterate through the sentences.  The Python code I am trying to replicate is: from nltk.corpus import gutenberg for i, fileid in en

Re: Can't get iterator in the C API

2022-02-09 Thread Jen Kris via Python-list
Thank you for clarifying that.  Now on to getting the iterator from the method.  Jen Feb 8, 2022, 18:10 by pyt...@mrabarnett.plus.com: > On 2022-02-09 01:12, Jen Kris via Python-list wrote: > >> I am using the Python C API to load the Gutenberg corpus from the nltk >> l

Can't get iterator in the C API

2022-02-08 Thread Jen Kris via Python-list
I am using the Python C API to load the Gutenberg corpus from the nltk library and iterate through the sentences.  The Python code I am trying to replicate is: from nltk.corpus import gutenberg for i, fileid in enumerate(gutenberg.fileids()):     sentences = gutenberg.sents(fileid)     et

Re: Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-02 Thread Jen Kris via Python-list
y is also not. > > -Original Message- > From: Dennis Lee Bieber > To: python-list@python.org > Sent: Wed, Feb 2, 2022 12:30 am > Subject: Re: Data unchanged when passing data to Python in multiprocessing > shared memory > > > On Wed, 2 Feb 2022 00:40:22 +0100

Re: Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-02 Thread Jen Kris via Python-list
Feb 1, 2022, 21:30 by wlfr...@ix.netcom.com: > On Wed, 2 Feb 2022 00:40:22 +0100 (CET), Jen Kris > declaimed the following: > >> >> breakup = int.from_bytes(byte_val, "big") >> > >print("this is breakup " + str(breakup)) > >> >> >

Re: Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-01 Thread Jen Kris via Python-list
ig endian.  However, if anyone on this list knows how to pass data from a non-Python language to Python in multiprocessing.shared_memory please let me (and the list) know.  Thanks.  Feb 1, 2022, 14:20 by ba...@barrys-emacs.org: > > >> On 1 Feb 2022, at 20:26, Jen Kris via Pyth

Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-01 Thread Jen Kris via Python-list
I am using multiprocesssing.shared_memory to pass data between NASM and Python.  The shared memory is created in NASM before Python is called.  Python connects to the shm:  shm_00 = shared_memory.SharedMemory(name='shm_object_00',create=False).  I have used shared memory at other points in thi

Re: Python child process in while True loop blocks parent

2021-12-08 Thread Jen Kris via Python-list
h ctypes.  If I use it as a C extension then I want the Python code on a separate thread because I can't have two instances of the Python interpreter running on one thread, and one instance will already be running on the main thread, albeit "suspended" by the call from ctypes. 

Re: Python child process in while True loop blocks parent

2021-12-06 Thread Jen Kris via Python-list
@barrys-emacs.org: > > >> On 6 Dec 2021, at 17:09, Jen Kris via Python-list >> wrote: >> >> I can't find any support for your comment that "Fork creates a new >> process and therefore also a new thread." From the Linux man pages >> htt

Re: Python child process in while True loop blocks parent

2021-12-06 Thread Jen Kris via Python-list
t;).  You may be confused by the fact that threads are called light-weight processes.  Or maybe I'm confused :) If you have other information, please let me know.  Thanks.  Jen Dec 5, 2021, 18:08 by hjp-pyt...@hjp.at: > On 2021-12-06 00:51:13 +0100, Jen Kris via Python-list wrote: >

Re: Python child process in while True loop blocks parent

2021-12-05 Thread Jen Kris via Python-list
e Python code than with C API code.  I hope that clarifies what I'm doing.  Jen Dec 5, 2021, 15:19 by ba...@barrys-emacs.org: > > > > >> On 5 Dec 2021, at 17:54, Jen Kris wrote: >> >>  >> Thanks for your comments.  >> >> I put the Pyth

Re: Python child process in while True loop blocks parent

2021-12-05 Thread Jen Kris via Python-list
s.org: > > >> On 1 Dec 2021, at 16:01, Jen Kris <>> jenk...@tutanota.com>> > wrote: >> >> Thanks for your comment re blocking.  >> >> I removed pipes from the Python and C programs to see if it blocks without >> them, and it does. >> >

Re: Python child process in while True loop blocks parent

2021-12-01 Thread Jen Kris via Python-list
> > > >> On 29 Nov 2021, at 22:31, Jen Kris <>> jenk...@tutanota.com>> > wrote: >> >> Thanks to you and Cameron for your replies.  The C side has an epoll_ctl >> set, but no event loop to handle it yet.  I'm putting that in now with a >

Re: Python child process in while True loop blocks parent

2021-11-29 Thread Jen Kris via Python-list
hat's nonblocking by default.  The child will become more complex, but not in a way that affects polling.  And thanks for the tip about the c-string termination.  Nov 29, 2021, 14:12 by ba...@barrys-emacs.org: > > >> On 29 Nov 2021, at 20:36, Jen Kris via Python-list >&

Python child process in while True loop blocks parent

2021-11-29 Thread Jen Kris via Python-list
I have a C program that forks to create a child process and uses execv to call a Python program.  The Python program communicates with the parent process (in C) through a FIFO pipe monitored with epoll().  The Python child process is in a while True loop, which is intended to keep it running w

GDAL Installation in Enthought Python Distribution

2015-02-25 Thread Leo Kris Palao
Hi Python Users, Would like to request how to install GDAL in my Enthought Python Distribution (64-bit). I am having some problems making GDAL work. Or can you point me into a blog that describes how to set up GDAL in Enthought Python Distribution. Thanks for any help. -Leo -- https://mail.pytho

Configuring problems with GDAL in enthought Python Canopy

2015-02-25 Thread Leo Kris Palao
Hi ALL, Just wanted to ask if somebody could guide me in installing GDAL in my Python installed using Canopy. Could you give me some steps how to successfully install this package? I got it running using my previous Python Installation, but I removed it and used Canopy Python now. btw: my python

Random forest and svm for remote sensing in python

2015-02-12 Thread Leo Kris Palao
Hi Python Users, Good day! I am currently using ENVI for my image processing/remote sensing work, but would love to divert into open source python programming for remote sensing. Can you give me some good sites where I can see practical examples of how python is used for remote sensing specially

Re: GDAL installation

2015-02-11 Thread Leo Kris Palao
-gdal-and-ogr-for-python-on-windows/ > > Asim > > On Tue, Feb 10, 2015 at 9:11 PM, Leo Kris Palao > wrote: > >> Hi Python Users, >> >> I currently installed the Python 2.7.9 and installed the GDAL package. >> First, I tried to install GDAL using PIP but it

GDAL installation

2015-02-10 Thread Leo Kris Palao
Hi Python Users, I currently installed the Python 2.7.9 and installed the GDAL package. First, I tried to install GDAL using PIP but it throws an error - I cannot remember the exact error message. So, I install it using easy_install command. But when I import the package I am getting this message,

Re: back with more issues

2013-08-12 Thread Kris Mesenbrink
the Classes and __init__ still don't make much sense actually. i have tried and tried again to make it generate numbers between 0 and 5 in a while statement but it just doesn't seem to be working. import random class Player(): hp = 10 def __init__(self, patt): self.att = rando

Re: back with more issues

2013-08-12 Thread Kris Mesenbrink
import random class player(): hp = 10 attack = random.randint(0,5) class monster(): hp = 10 attack = random.randint(0,4) def battle(): print ("a wild mosnter appered!") print ("would you like to battle?") answer = input() if answer == ("yes"): while monst

Re: back with more issues

2013-08-11 Thread Kris Mesenbrink
darn i was hoping i could put off learning classes for a bit, but it seems that is not the case. i have tested it a bit and it seems to be working correctly now. import random class player(): hp = 10 speed = 5 attack = random.randint(0,5) print (player.

Re: back with more issues

2013-08-11 Thread Kris Mesenbrink
the idea was to store variables for later use, but you are correct i don't understand functions or if that is even the best way to do it. i guess i'd want to be able to call the HP and ATTACK variables of player for when the battle gets called. i would then use the variables in battle to figure

back with more issues

2013-08-11 Thread Kris Mesenbrink
import random def player(): hp = 10 speed = 5 attack = random.randint(0,5) def monster (): hp = 10 speed = 4 def battle(player): print ("a wild mosnter appered!") print ("would you like to battle?") answer = input() if answer == ("yes"): return player(

Re: Issues with if and elif statements in 3.3

2013-08-08 Thread Kris Mesenbrink
WOW as if it was something as easy as that,i had been looking for awhile on what i was doing wrong. as it seems i just don't know my way around if statements at all, thank a bunch for this. makes everything else i have been code work thanks again -- http://mail.python.org/mailman/listinfo/pyt

Program blocked in Queue.Queue.get and Queue.Queue.put

2012-01-04 Thread Kris
I have a program that is blocked and all threads are blocked on a Queue.Queue.get or Queue.Queue.put method (on the same Queue.Queue object). 1 thread shows the below as its last entry in the stack: File: "c:\python27\lib\Queue.py", line 161, in get self.not_empty.acquire() 2 threads show the b

Re: In-place memory manager, mmap

2008-08-24 Thread Kris Kennaway
castironpi wrote: On Aug 24, 9:52 am, Kris Kennaway <[EMAIL PROTECTED]> wrote: castironpi wrote: Hi, I've got an "in-place" memory manager that uses a disk-backed memory- mapped buffer. Among its possibilities are: storing variable-length strings and structure

Re: In-place memory manager, mmap (was: Fastest way to store ints and floats on disk)

2008-08-24 Thread Kris Kennaway
open-source it. Any interest? Just do it. That way users can come along later. Kris -- http://mail.python.org/mailman/listinfo/python-list

Re: benchmark

2008-08-11 Thread Kris Kennaway
Peter Otten wrote: Kris Kennaway wrote: Peter Otten wrote: [EMAIL PROTECTED] wrote: On Aug 10, 10:10 pm, Kris Kennaway <[EMAIL PROTECTED]> wrote: jlist wrote: I think what makes more sense is to compare the code one most typically writes. In my case, I always use range() and nev

Re: SSH utility

2008-08-11 Thread Kris Kennaway
tricky and not something I want to trust to projects that have not had significant experience and auditing. Kris -- http://mail.python.org/mailman/listinfo/python-list

Re: benchmark

2008-08-11 Thread Kris Kennaway
Peter Otten wrote: [EMAIL PROTECTED] wrote: On Aug 10, 10:10 pm, Kris Kennaway <[EMAIL PROTECTED]> wrote: jlist wrote: I think what makes more sense is to compare the code one most typically writes. In my case, I always use range() and never use psyco. But I guess for most of my wor

Re: Constructing MIME message without loading message stream

2008-08-10 Thread Kris Kennaway
Diez B. Roggisch wrote: Kris Kennaway schrieb: I would like to MIME encode a message from a large file without first loading the file into memory. Assume the file has been pre-encoded on disk (actually I am using encode_7or8bit, so the encoding should be null). Is there a way to construct

Re: benchmark

2008-08-10 Thread Kris Kennaway
yet, where performance starts to matter. Hopefully when you do you will improve your programming practices to not make poor choices - there are few excuses for not using xrange ;) Kris -- http://mail.python.org/mailman/listinfo/python-list

Re: benchmark

2008-08-10 Thread Kris Kennaway
What is the standard deviation on those numbers? What is the confidence level that they are distinct? In a thread complaining about poor benchmarking it's disappointing to see crappy test methodology being used to try and demonstrate flaws in the test. Kris -- http://mail.python.org/mailman/listinfo/python-list

Constructing MIME message without loading message stream

2008-08-09 Thread Kris Kennaway
streamed from the file as needed instead of being resident in memory? Do I have to subclass the MIMEBase class myself? Kris -- http://mail.python.org/mailman/listinfo/python-list

Re: variable expansion with sqlite

2008-08-08 Thread Kris Kennaway
ameters you are passing in are safe. Kris -- http://mail.python.org/mailman/listinfo/python-list

Re: pyprocessing/multiprocessing for x64?

2008-08-07 Thread Kris Kennaway
Benjamin Kaplan wrote: The only problem I can see is that 32-bit programs can't access 64-bit dlls, so the OP might have to install the 32-bit version of Python for it to work. Anyway, all of this is beside the point, because the multiprocessing module works fine on amd64 systems.

Re: multithreading in python ???

2008-07-10 Thread Kris Kennaway
on a single CPU at a time. Depending on what modules you use they may be able to operate independently on multiple CPUs. The term to research is "GIL" (Global Interpreter Lock). There are many webpages discussing it, and the alternative strategies you can use. Kris -- http://mail.

Re: re.search much slower then grep on some regular expressions

2008-07-10 Thread Kris Kennaway
J. Cliff Dyer wrote: On Wed, 2008-07-09 at 12:29 -0700, samwyse wrote: On Jul 8, 11:01 am, Kris Kennaway <[EMAIL PROTECTED]> wrote: samwyse wrote: You might want to look at Plex. http://www.cosc.canterbury.ac.nz/greg.ewing/python/Plex/ "Another advantage of Plex is that it compiles

Re: re.search much slower then grep on some regular expressions

2008-07-10 Thread Kris Kennaway
wer like Python's re to search the remainder of the line for 'bar.*zot'. If it was just strings, then sure...with regexps it might be possible to make it work, but it doesn't sound particularly maintainable. I will stick with my shell script until python gets a regexp

Re: re.search much slower then grep on some regular expressions

2008-07-09 Thread Kris Kennaway
samwyse wrote: On Jul 8, 11:01 am, Kris Kennaway <[EMAIL PROTECTED]> wrote: samwyse wrote: You might want to look at Plex. http://www.cosc.canterbury.ac.nz/greg.ewing/python/Plex/ "Another advantage of Plex is that it compiles all of the regular expressions into a single DFA.

Re: re.search much slower then grep on some regular expressions

2008-07-09 Thread Kris Kennaway
Jeroen Ruigrok van der Werven wrote: -On [20080709 14:08], Kris Kennaway ([EMAIL PROTECTED]) wrote: It's compiler/build output. Sounds like the FreeBSD ports build cluster. :) Yes indeed! Kris, have you tried a PGO build of Python with your specific usage? I cannot guarantee it

Re: re.search much slower then grep on some regular expressions

2008-07-09 Thread Kris Kennaway
, postscript paper and C source findable from Gonzalo Navarro's home- page. Thanks, looks interesting but I don't think it is the best fit here. I would like to avoid spawning hundreds of processes to process each file (since I have tens of thousands of them to process). Kris -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search much slower then grep on some regular expressions

2008-07-08 Thread Kris Kennaway
ger compilation time (over a minute). If the matching was fast then I could possibly pickle the lexer though (but it's not). Kris Kris -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search much slower then grep on some regular expressions

2008-07-08 Thread Kris Kennaway
a time proportional to the number of characters to be scanned, and independent of the number or complexity of the regular expressions. Python's existing regular expression matchers do not have this property. " Very interesting! Thanks very much for the pointer. Kris -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search much slower then grep on some regular expressions

2008-07-07 Thread Kris Kennaway
ed in but I can and do :-) It's a major problem that regular expression parsing in python has exponential complexity when polynomial algorithms (for a subset of regexp expressions, e.g. excluding back-references) are well-known. It rules out using python for entire classes of applicatio

Re: Bit substring search

2008-06-25 Thread Kris Kennaway
Scott David Daniels wrote: Kris Kennaway wrote: Thanks for the pointers, I think a C extension will end up being the way to go, unless someone has beaten me to it and I just haven't found it yet. Depending on the pattern length you are targeting, it may be fastest to increase the out-of

  1   2   >