In article ,
Henning Follmann wrote:
>On 2021-02-10, Python wrote:
>> Hi,
>>
>> If you had to train engineers who are used to write
>> Python scripts for image processing, data format conversion,
>> etc. (so they know most the basics of Python types and
>> programming structures except advance
In article ,
Henning Follmann wrote:
>>>Looks like you (the project leader?) needs training, not the
>>>software engineers.
>>>
>>>"Making Things Happen" by Scott Berkun
>>
>> This looks like a very interesting book to add to my reading list, but
>> how do you think it will help the OP with his/
Is this:
a) a bug in getopt.getopt
b) a bug in my code
c) a great way to keep me busy for a while
d) all of the above?
#!/usr/bin/python
from __future__ import print_function
from getopt import getopt, GetoptError
import sys
try:
opts, args = getopt(sys.argv[1:], 'b', ['bug '])
except Ge
In article ,
Chris Angelico wrote:
>On Mon, Jul 4, 2016 at 9:24 PM, Oscar wrote:
>> Is this:
>>
>> a) a bug in getopt.getopt
>> b) a bug in my code
>> c) a great way to keep me busy for a while
>> d) all of the above?
>>
>>
>> #!/u
In article ,
Chris Angelico wrote:
>On Wed, Jul 6, 2016 at 2:04 PM, Lawrence DâOliveiro
> wrote:
>> On Tuesday, July 5, 2016 at 1:42:42 AM UTC+12, Chris Angelico wrote:
>>
>>> The getopt module is designed to match the C getopt function, which I've
>>> never used; for my command-line parsing, I
In article ,
Chris Angelico wrote:
>Yes, it's a third-party dependency. (Sorry, should have mentioned
>that.) You're welcome to consider that to be too much risk and/or
>hassle to be worth improving on getopt, but personally, I *really*
>like the simplicity of just writing docstrings that still r
In article ,
Bischoop wrote:
>I've also convert the choice to int() but doesn't help.
Oh.. did not read this yet. How did you do this? In both places after
the input or during the comparison? If so, in which version? Only the
first version would work. The other two are just plain wrong.
--
[J|O
In article <5fd465b5$0$8956$426a7...@news.free.fr>, ast wrote:
>Hello
>
>In case a function recursively calls itself many times,
>is there a way to return a data immediately without
>unstacking all functions ?
If you are referring to your "are you ok?" problem, please read up on
recursion and wh
In article ,
Bischoop wrote:
>
>I need to check if input number is 1-5. Whatever I try it's not working.
>Here are my aproaches to the problem: https://bpa.st/H62A
>
>What I'm doing wrong and how I should do it?
You need to learn about types. ;-)
Input returns a string. That string is not in th
In article <5fd4f4b5$0$8928$426a7...@news.free.fr>, ast wrote:
>Le 12/12/2020 à 17:10, Oscar a écrit :
>> In article <5fd465b5$0$8956$426a7...@news.free.fr>, ast wrote:
>>> Hello
>>>
>>> In case a function recursively calls itself many times,
In article ,
wrote:
buffer = ('a'*998 + '\u20ac').encode('utf-8')[:1000]
buffer.decode('utf-8')
>Traceback (most recent call last):
> File "", line 1, in
>UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 998-999:
>unexpected end of data
# BOUM
hmm...
>>>
PyDev plugin is excelent!
it's easy for me to debug python scripts,but the ECLIPSE needs more
memory to run .
--
http://mail.python.org/mailman/listinfo/python-list
/// Foo.cpp
class CFoo
{
};
# Test.py
#i use foo.cpp build the 'foo' module
import foo
#param : CFoo
def bar(o):
#call the object o's member functions
at last,i call the bar() function in my main.cpp.
///main.cpp
CFoo foo;
/// how to pass foo to the function 'bar'
now, i use the binder
active
while start of next_starting > end of next_ending:
report active events from now to end of next_ending
now = end of next_ending
remove next_ending from active
report active events from now until start of next_starting
now = start of next_starting
add next_starting to active
And some more code to deal with what happens when you get to the end
of the list of events...
The report steps probably mean adding to a Counter or dict to remember
that the currently active events were active during each particular
time window.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
e system is
> all you want to do. That's why, for example, the unix "touch" command
> exists.
Wouldn't the code that implements the touch command just look
something like this:
f = open(filename)
f.close()
Or is there some other way of creating the file that doesn't o
ubclass B because
the B part of the object isn't initialised when the A constructor is
called. There may be a better way to do this since I last used C++ but
as I remember it the two-phase pattern was a recommended way to
implement polymorphic behaviour during initialisation.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
lusion:
"Never use positional arguments in __init__ or __new__. Always use
keyword args, and always call them as keywords, and always pass all
keywords on to super."
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
rse, e.g. parsing sys.argv for
> short/long options, flag/parameter options etc.
>
> I was thinking of maybe some sort of flag that argparse sets on those
> optional arguments created with add_argument() that are really given on the
> command line, i.e. those that it stumbles upon
On 16 May 2013 03:06, Steven D'Aprano
wrote:
> On Wed, 15 May 2013 13:16:09 +0100, Oscar Benjamin wrote:
>
>
>> I don't generally use super()
>
> Then you should, especially in Python 3.
>
> If you're not using super in single-inheritance classes, then y
, 2.47213595,
0., 2.28230601, 0., 2.15105461,
0., 2.06487174, 0., 2.01589594, 0.])
Find the index of the maximum element:
>>> np.argmax(spect)
1
So the peak is the lowest non-zero frequency component of the DFT. In
Hz
words to the problem: apodization, zero filling, convolution
> product, ...
>
> eg. http://en.wikipedia.org/wiki/Convolution
These points are not relevant to the example given.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
lenames)] if x])
Do you find this code easy to read? I wouldn't write something like
this and I certainly wouldn't use it when explaining something to a
beginner.
Rather than repeated list comprehensions you should consider using a
single loop e.g.:
for filename in filenames:
# process each file
This will make the code a lot simpler.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
e.
However no one has written a patch for it. Why don't you look into
what it would take to make it happen?
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 23 May 2013 00:49, Carlos Nepomuceno wrote:
>
> The code is pretty obvious to me, I mean there's no obfuscation at all.
I honestly can't tell if you're joking.
--
http://mail.python.org/mailman/listinfo/python-list
]
if mean(column1) == 50:
print('File "{}" has 1st row average =
{:.2f}'.format(filename, mean(row1)))
It's all a little easier if you use numpy:
import numpy as np
filenames = ['1.txt', '2.txt', '3.txt', '4.txt'
at the broken() function is doing is totally stupid: responding to a
recursion error with more recursion. However this may indicate or be
considered a bug in the 3.x interpreter.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 29 May 2013 14:02, Dave Angel wrote:
> On 05/29/2013 08:45 AM, Oscar Benjamin wrote:
>
> More likely a bug in the 2.x interpreter. Once inside an exception handler,
> that frame must be held somehow. If not on the stack, then in some separate
> list. So the logic will presuma
gt;> abs(z)
1.4142135623730951
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
hing like:
eps = 1e-7
true_answer = 123.4567879
estimate = myfunc(5)
assert abs(estimate - true_answer) < eps * abs(true_answer)
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
ngs.append(s)
but then we're back where we started. I don't think any of the
solutions posted in this thread have been better than this. If you
want to make this a nice one-liner then just put this code in a
function.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
anyone. It also
reduces the chance of accidentally replying off-list. Anyone who wants
to reply off-list or to deliberately CC someone (as I did here) can
still do so but it will rarely happen accidentally.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
it essentially
just says that you can use it anywhere you like for anything you want
without paying any money.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
nto a standalone executable file although a number
of projects exist to make that possible. Is it so hard for your users
to install Python and Blender if you tell them which files to download
and install?
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
you have the option to bundle the C runtime
DLL with you application.
'''
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
by '(' in
normal mode. It will jump backwards to the first unmatched opening
bracket. Use ]) to find the next unmatched closing bracket. You can
also do [{ and ]} for curly brackets. I'm not sure how to do square
brackets - [[ and ]] are used for navigating between functions.
Osc
nk it easier to wrap getopt than monkey-patch argparse in this way.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
olling and how to deal with trolls. I can see how some are annoyed
by Νίκος and his posts but I for one am *much more* concerned/bothered
by the surrounding (often highly) unpleasant discussion by others.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
here the top answer is actually a quote
linking back to the previous post in this same thread?
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 5 July 2013 02:24, Cameron Simpson wrote:
> On 04Jul2013 16:03, Oscar Benjamin wrote:
> |
> | Is there some reason you're responding to a post from 5 years ago?
>
> Is there some reason not to, if no newer solutions are available?
No, I was genuinely curious. My way of
not as good as lists for this kind of looping and indexing.
I would actually expect this program to run faster with ordinary
Python lists and lists of lists. It means that you need to change e.g.
Grid[r, c] to Grid[r][c] but really I think that the indexing syntax
is all you're getting out of numpy here.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
ed then this could be a significant improvement.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 5 July 2013 15:28, Helmut Jarausch wrote:
> On Fri, 05 Jul 2013 14:41:23 +0100, Oscar Benjamin wrote:
>
>> On 5 July 2013 11:53, Helmut Jarausch wrote:
>>> I even tried to use dictionaries instead of Numpy arrays. This version is a
>>> bit
>>> slow
ke the stdlib array type Steven referred to) they use
homogeneous types in a contiguous buffer and each element is not a
Python object in its own right until you access it with e.g. a[0].
That means that the numpy array has to create a new object every time
you index into it whereas the list can simply return a new reference
to an existing object. You can get the same effect with numpy arrays
by using dtype=object but I'd still expect it to be slower for this.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
; return False
>
> which turns out to be as fast as the previous "dictionary only version".
> Probably, set.remove is a bit slow
No it's not and you're not using it in your innermost loops anyway.
Probably the loop I referred to isn't your bottleneck.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
nerator function.
Or you can use itertools.imap:
def xslice(sequence, start_or_stop, *args):
indices = xrange(*slice(start_or_stop, *args).indices(len(sequence)))
return imap(sequence.__getitem__, indices)
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 11 July 2013 17:21, Russel Walker wrote:
> To confess, this is the second time I've made the mistake of trying to
> implement generator like functionality of a builtin when there already is on
> in itertools. Need to start studying that module abit more I think. I'm
> looking at the docs now
o
iterate over it explicitly or implicitly (set, sorted, max,...)?
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 24, 2013 2:27 PM, "Peter Otten" <__pete...@web.de> wrote:
>
> Oscar Benjamin wrote:
>
> > On Jul 24, 2013 7:25 AM, "Peter Otten" <__pete...@web.de> wrote:
> >>
> >> Ethan Furman wrote:
> >>
> >> > So, m
Fraction
"literals" is to do:
from fractions import Fraction as F
# 1/3 + 1/9 + 1/27 + ...
limit = F('1/3') / (1 - F('1/3'))
That's not as good as dedicated syntax but with code highlighting it's
still quite readable.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 19 June 2012 00:53, Jason Friedman wrote:
> Which leads me to another question ... how can I debug these things?
>
> $ echo 'hello' | python3 -m pdb ~/my-input.py
> > /home/jason/my-input.py(2)()
> -> import sys
> (Pdb) *** NameError: name 'hello' is not defined
> --
> http://mail.python.org/m
On 25 June 2012 08:24, Stefan Behnel wrote:
> Saurabh Kabra, 25.06.2012 05:37:
> > I have written a script to map a 2D numpy array(A) onto another array(B)
> of
> > different dimension. more than one element (of array A) are summed and
> > mapped to each element of array B. To achieve this I cre
he
indices.
In my experience the fastest way to do something like this would be to use
cython as suggested above by Stefan.
Oscar.
>
> Saurabh
>
>
>
>
>
> On 25 June 2012 08:24, Stefan Behnel
> wrote:
>
> Saurabh Kabra, 25.06.2012 05:37:
>> > I have wr
On 11 July 2012 19:15, wrote:
> On Tuesday, July 10, 2012 11:16:08 PM UTC+5:30, Subhabrata wrote:
> > Dear Group,
> >
> > I kept a good number of files in a folder. Now I want to read all of
> > them. They are in different formats and different encoding. Using
> > listdir/glob.glob I am able to f
estart behaviour: if flag is False, system calls will
be restarted when interrupted by signal signalnum, otherwise system calls
will be interrupted. Returns nothing. Availability: Unix
'"""
Cheers,
Oscar.
--
http://mail.python.org/mailman/listinfo/python-list
...:
In [2]: class B(object):
...: def __repr__(self):
...: return 'foo'
...:
In [3]: a = A()
In [4]: b = B()
In [5]: repr(a)
Out[5]: '<__main__.A object at 0x2136b10>'
In [6]: repr(b)
Out[6]: 'foo'
In [7]: object.__repr__(b)
Out[7]:
On 23 July 2012 01:24, Steven D'Aprano wrote:
> On Mon, 23 Jul 2012 08:54:00 +1000, Chris Angelico wrote:
>
> > On Mon, Jul 23, 2012 at 8:48 AM, Dan Stromberg
> > wrote:
> >> If a class has defined its own __repr__ method, is there a way of
> >> getting the default repr output for that class any
er input file (as are file1.txt and file2.txt).
>
I haven't used subparsers in argparse but I imagine that you would call it
like:
$ mytool.py foo file1.txt file2.txt
Cheers,
Oscar.
>
> Any help would be appreciated.
> Ben.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
om the command line if possible, and produced as a single item".
> So you can't pass several arguments to the program.
Right below that in the docs it explains about using nargs='*' and
nargs='+'. One of those will do what you want.
Oscar.
>
> So, to rephras
program does not work like
a "standard unix tool". A standard command line program to do what you want
would normally look like
$ python toto.py foo -n 10 foo.txt bar.txt
or perhaps
$ python toto.py foo foo.txt bar.txt -n 10
so that the algorithm for differentiating the command
answer to your
question. Why are you copying? What are you copying? Do you need a
deep-copy?
I don't really know what you're doing but my first approach would be to try
and reduce or eliminate the deep copies rather than implement them in c.
Oscar.
>
>
>
>
>
>
On 31 July 2012 13:51, Benoist Laurent wrote:
>
> Le Jul 31, 2012 à 1:45 PM, Oscar Benjamin a écrit :
>
>
>
> On 31 July 2012 12:03, Benoist Laurent wrote:
>
>> Finally.
>>
>> The code I proposed doesn't work in this case: if you add any positional
&g
Are you familiar with the itertools module?
itertools.product is designed for this purpose:
http://docs.python.org/library/itertools#itertools.product
Oscar.
On 6 August 2012 16:52, Tom P wrote:
> consider a nested loop algorithm -
>
> for i in range(100):
> for j
On 6 August 2012 16:52, Tom P wrote:
> consider a nested loop algorithm -
>
> for i in range(100):
> for j in range(100):
> do_something(i,j)
>
> Now, suppose I don't want to use i = 0 and j = 0 as initial values, but
> some other values i = N and j = M, and I want to iterate through
d then range(0,M), and i runs through
> range(N,100) and then range(0,N)
>
> .. apologies if I didn't make that clear enough.
How about range(N, 100) + range(0, N)?
Example (Python 2.x):
>>> range(3, 10)
[3, 4, 5, 6, 7, 8, 9]
>>> range(0, 3)
[0, 1, 2]
>>> range(3, 10) + range(0, 3)
[3, 4, 5, 6, 7, 8, 9, 0, 1, 2]
In Python 3.x you'd need to do list(range(...)) + list(range(...)) or use
itertools.chain.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
read.
2) You don't need to call str() on any of your arguments.
3) It's also more efficient (in some cases).
You can also use named parameters in the format string:
"I'm a {name} class spaceship and I have {number} engines".format(name=
self.name, number=self.engines)
There is also the older, deprecated (but not about to be removed) method:
"I'm a %s class spaceship and I have %i engines" % (self.name, self.engines)
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
4 4 2
> 2 3 1
> 4 3 2
> Any ideas?
> Thanks in advance
How's this?
from __future__ import print_function
output = open("out.txt", "w")
for (a, b), c in d.items():
print(a, b, c, file=output)
output.close()
Oscar.
> --
> http://mail.python.org/mailman/l
> What do you think? is there a way to speed up the process?
> Thanks
> Giuseppe
Which part is slow? How slow is it?
A simple test to find the slow part of your code is to print messages
between the commands so that you can see how long it takes between each
message.
Oscar.
d
> read the image line by line.
> Thanks
> ciao
That does seem slow. I'm sure it can be a lot faster than that.
Did you also write the code for reading the arrays? The loop can certainly
be made faster but if you can't make the array reading faster there's not
much point s
s behaviour.
Unless others are unable to reproduce your observations.
If there is a big performance hit for text heavy applications then it's
worth reporting but you should focus your energy on distilling a
*meaningful* test case (rather than ranting about Americans, unicode,
latin-1 a
é')")
> 7.560455708007855
>
> Maybe, not so demonstative. It shows at least, we
> are far away from the 10-30% "annouced".
>
> >>> 7.56 / 5
> 1.512
> >>> 5 / (7.56 - 5) * 100
> 195.312503
Maybe the problem is that your understanding
becomes
large because of changes in other variables. If k is small then you
can often guess that O(k) is small. To say that an operation is O(k),
however, is a statement about what happens when k is big (and is not
refuted by saying that k is typically not big).
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 20 August 2012 17:01, Paul Rubin wrote:
> Oscar Benjamin writes:
> > No it doen't. It is still O(k). The point of big O notation is to
> > understand the asymptotic behaviour of one variable as it becomes
> > large because of changes in other variables.
>
>
o not know is how to make it do the casting properly without
losing the 10x speedup of FastStorage over SlowStorage.
Any idea?
I don't really understand what your trying to do but since you didn't
add the __setattr__ method to FastStorage the item is not added to
the dictionary when you do a.x = 1
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 21 August 2012 13:52, Massimo Di Pierro wrote:
> On Aug 21, 2:40 am, Oscar Benjamin wrote:
> > On Mon, 20 Aug 2012 21:17:15 -0700 (PDT), Massimo Di Pierro
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > wrote:
> > > Con
On 21 August 2012 14:50, Massimo Di Pierro wrote:
> Hello Oscar,
>
> thanks for your help but your proposal of adding:
>
> def __setitem__(self,key,value):
>self.__dict__[key] = value
>dict.__setitem__(self, key, value)
>
> does not help me.
>
> What I
On 21 August 2012 16:19, Oscar Benjamin wrote:
>
> On Aug 21, 2012 3:42 PM, "Massimo DiPierro"
> wrote:
> >
> > Thanks again Oscar. I cannot do that. I have tight constraints. I am not
> at liberty to modify the code that uses the class. The exposed API cannot
&
. x = 1/0
...
>>> x
42
>>> with safe(42) as x:
... x = 'qwe'
...
>>> x
'qwe'
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
le = f.read()
if '' in nomefile:
print('NOK')
**
But this one works on charachters and not on strings (i.e.: in this
way I h=
ave searched NOT string by string, but charachters-by-charachters).
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
you'd need to do:
self.d = 'my attribute'
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
that class.
Builtin types show as type and classes defined in python show as
class (even if they inherit from builtin types).
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
print(x)
f2() # 10
f1() # 4
f2() # still 10
If you want f1 to modify the value of x seen by f2 then you should
explicitly declare x as global in f1.
Likewise if you want to modify an attribute for all instances of a class
you should explicitly assign to the class attribute rather than an instance
attribute.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
n anyone give me some idea's or tell me which structure would be
> best to use?
>
The above method for storing the data on disk is simple but not very safe.
If you use it for your wife's business make sure that you are always
keeping backups of the file. Preferably don't overwrite the file directly
but write the data out to a separate file first and then rename the file
(to avoid loss of data if the program has an error while writing).
The obvious way to improve on the above is to use the sqlite3 module to
store the data in an sqlite3 file instead of a csv file. There is one
advantage to using the above over using an sqlite3 database which is that
the data can be edited manually as a text file or using standard
spreadsheet software if necessary.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
#x27; result
above. Applying this to real data is obviously more complicated since
successive characters are not independent but it would be a fairly unusual
situation if you were not more likely to stop at an earlier point in the
comparison loop than a later one.
Oscar.
--
http://mail.python.org/mailman/listinfo/python-list
se
strings composed entirely from a set of 1 possible character. Not only does
this do away with all of the inherent performance problems of flexible
string representations but it results in O(0) comparison complexity (far
outstripping previous Python versions).
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
827173, 0.22008216041484274,
0.22567319461444307, 0.10440677966101695, 0.18181818181818182,
0.35714285714285715]
A notable outlier in these sequences is for comparing the first character
of the two words which is why for this string distribution it is better to
start at the beginning than the end.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
cases where the pathological data can occur (such as with file
paths). However, I suspect that out of all the different uses of python
strings these cases are a small minority.
In saying that, it's not inconceivable that someone could exploit string
comparison by providing pathological data to make normally O(1) operations
behave as O(N). If I understand correctly it was precisely this kind of
problem with dict insertion/lookup that lead to the recent hash-seed security
update.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
ou can obtain this result analytically from
Johannes' formula above. Just replace 256 with 10 to get that the
expected number of comparisons is
(10/9)*(1 - 10**(-N))
The last term shows the dependence on N and is tiny even for N=9.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
gt; for M = 3, the average approaches 1.5, for M = 4 it approaches 1.333...
> and so forth.
It approaches 1 / (1 - p) or, if you prefer: M / (M - 1)
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 2012-09-07, Oscar Benjamin wrote:
> On 2012-09-07, Steven D'Aprano wrote:
>>
>
> Since string comparison is only useful if the strings can be equal or unequal,
> the average case depends on how often they are equal/unequal as well as the
> average complexity of bo
On 2012-09-08, Steven D'Aprano wrote:
> On Fri, 07 Sep 2012 19:10:16 +0000, Oscar Benjamin wrote:
>
>> On 2012-09-07, Steven D'Aprano
>> wrote:
>>
>>
>> Would you say, then, that dict insertion is O(N)?
>
> Pedantically, yes.
>
ns to the
>> idea.
I don't have much experience with the event-driven frameworks but having made
a couple of simple scripts using gevent/Twisted my experience is that learning
to use these frameworks is hard, largely because of the number of framework-
specific concepts that are
then s != t as well".
>
I thought that if *both* strings were interned then a pointer comparison could
decide if they were unequal without needing to check the characters.
Have I misunderstood how intern() works?
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 2012-09-10, Chris Angelico wrote:
> On Tue, Sep 11, 2012 at 12:06 AM, Oscar Benjamin
> wrote:
>> On 2012-09-10, Steven D'Aprano wrote:
>>> What interning buys you is that "s == t" is an O(1) pointer compare if
>>> they are equal. But if s an
On 2012-09-10, Oscar Benjamin wrote:
> On 2012-09-10, Chris Angelico wrote:
>> On Tue, Sep 11, 2012 at 12:06 AM, Oscar Benjamin
>> wrote:
>>> On 2012-09-10, Steven D'Aprano wrote:
>>>> What interning buys you is that "s == t" is an O(1) poi
the hash value once computed is stored on the string
object itself [1] and used for subsequent string comparisons so there's no
need for you to do that in your code.
Oscar
[1] http://hg.python.org/cpython/file/71d94e79b0c3/Include/unicodeobject.h#l293
--
http://mail.python.org/mailman/listinfo/python-list
n is that string
comparison always compares the characters in the same order and it corresponds
to the natural ordering of the data. This means that some pefectly natural use
cases like comparing file-paths can have close to worst case behaviour. If
string/sequence comparison occurs in a random order then there can be no use
case where the likely strings would induce close to worst case behaviour
unless you really are just comparing lots of almost identical sequences.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
On 11 September 2012 10:51, Duncan Booth wrote:
> Oscar Benjamin wrote:
>
> >> What interning buys you is that "s == t" is an O(1) pointer compare
> >> if they are equal. But if s and t differ in the last character,
> >> __eq__ will still inspe
on whether
or not your parallel processes need to communicate with one another. I'm
assuming that you really just want to run independent jobs simultaneously.
Otherwise the other suggestions may be more relevant.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
object.__init__(self)
self.name = None
Remove the line above. The instance attribute self.name is hiding the
class attribute cls.name.
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
f
values:
lambda y: 1 <= y[0] <= 5
lambda y: y[0] + y[2] >= 3
If all of your constraints are linear (like all of the ones you have shown)
then you can represent each one as a set of coefficients for a linear
projection of the list combined with a threshold value (if this last point
doesn't make sense then just ignore it).
Oscar
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 654 matches
Mail list logo