> even more optimizations can be made at runtime. Much of that is just not
> possible in Python. No amount of compiler improvements and optimizations can
> change this.
Unless someone comes up with a really smart profiling jit. Like, I
believe, they're doing with the javascript engines. :-). And g
Hi,
I don't think you should see and difference in performance. Lists
might take a bit more space since they usually preallocate memory for
future inserts.
I'd go for lists where ever i need to use an array or a list, and
tuples for storing records.
Regards,
Sidharth
On Tue, Dec 22, 2009 a
This is to allow the alternate implementations to catch up, and not
really about the users of the python language. Adding breaking changes
between versions of python 3 would just be bad language design, so
users should be fine either way.
I've found myself quite happy using many of the new feature
Ah yes, silly me. Must remember to go to the docs before posting :">.
On Mon, Oct 26, 2009 at 2:12 AM, bhaskar jain
wrote:
> On Mon, Oct 26, 2009 at 1:53 AM, Sidharth Kuruvila <
> sidharth.kuruv...@gmail.com> wrote:
>>>>It turns out any object that returns
behaviour holds in python 3?
Regards,
Sidharth
On Mon, Oct 26, 2009 at 1:43 AM, Sidharth Kuruvila
wrote:
> Hi,
>
> I don't have elementree, so I just wanted to confirm what is
> happening here. Is it that the Element type is a subclass of list.
> Which would lead an empty Elem
Hi,
I don't have elementree, so I just wanted to confirm what is
happening here. Is it that the Element type is a subclass of list.
Which would lead an empty Element to have the same boolean property as
an empty list.
Or is there some way of specifying the truthfulness of an object.
Regards,
S
Hi,
The sort method doesn't return anything. It modifies the list which
you call it on.
l = d.keys()
l.sort() #There is no point assigning the return value to this because
it will be None
#Which is what you do when you write l = d.keys().sort()
print l
Now there is another subtle issue here wi
Hi Anand.
> Looks like Python dictionary implementation is doing something clever.
> d.keys() returns the cached object if its refcount == 1 and returns a
> new object if refcount > 1.
>
I don't think that's what's happening
>>> id(d.keys())
535168
>>> id(d.keys())
535168
>>> l = [1,2,3,4]
>>> i
ought up this http://www.python.org/dev/peps/pep-0372/.
Regards,
Sidharth
On Sat, Oct 24, 2009 at 3:23 PM, Sidharth Kuruvila
wrote:
> Hi,
>
>>>> d = {"a":1, "b":2}
>>>> d.keys()
> ['a', 'b']
>>>> a = d.keys()
>&
Hi,
>>> d = {"a":1, "b":2}
>>> d.keys()
['a', 'b']
>>> a = d.keys()
>>> b = d.keys()
>>> id(a)
542120
>>> id(b)
542200
So d creates a new list with each call to keys.
The behavior might be different in python 3 where I hear d.keys() will
return a set
Regards,
Sidharth
On Sat, Oct 24, 2009 at 2
Hi,
My bad, that was a bit of laziness on my part. The reason why my
code was silly is not to do with interning though that does happen for
strings. Literals, that is numbers and string literals and a few
others are loaded as constants. So the cost of constructing them in
your code has already be
Hi,
d = {"a":"Hello"}
print d.setdefault("a", "blah")
Even though the string blah is not being used an object has to be
created to represent it. Even worse, you could put some complex
expression in there expecting it to evaluate only if the key is
missing.
Regards,
Sidharth
On Wed, Oct 21,
s to,
>> print (str.translate(trantab))
>>
>> And you don't need semi-colons in Python. Semi-colons
>> are used only to separate 2 expressions in the same line.
>> Something like
>>
>> x=2; print x
>>
>> Here they are superfluous.
>>
>> And I think &
trantab = intab.maketrans(outtab)
> str = "this is string examplewow!!!";
> print str.translate(trantab);
>
> Thanks for the response.
> I changed the code as above
> this code too shows an error.
>
> On Tue, Oct 20, 2009 at 2:23 PM, Sid
Hi,
This looks like it's because python's strings have change in python 3.
The characters used to be 8bit bytes but now they are 16 bits wide.
A quick google tells me that str now has a method called maketrans so
s1.maketrans(s2) should work.
I'm guessing you are using a tutorial written for one
Hi,
There's jython http://www.jython.org/. I don't know if it will run on j2me.
Regards,
Sidharth
On Sun, Oct 18, 2009 at 6:38 PM, Aneesh A wrote:
> I and my friend like to do a mobile application in python.
>
> It should be working on most of mobiles.
>
> Is there any python interpreter that
AKA The Y Combinator in python. This is in response to Roshan Mathews'
post that he got stuck with the Y Combinator.
Aha a challenge, I shall undertake this as a test of my communication
skillz. :-)
The question is how do we implement a recursive function in a language
in which names can only be
Oops formatting got mucked up. Should be
def pickledobjects(f):
try:
while True:
yield pickle.load(f)
except EOFError:
pass
objs = list(pickledobjects(file("fi")))
___
BangPypers mailing list
BangPypers@python.org
htt
Hi,
I'm guessing you want to do something like this
>>> fo = file("test.pkl", "w")
>>> pickle.dump([1,2,3,4], fo)
>>> pickle.dump([5,6,7,8], fo)
>>> fo.close()
>>> fi = file("test.pkl")
>>> pickle.load(fi)
[1, 2, 3, 4]
>>> pickle.load(fi)
[5, 6, 7, 8]
>>> pickle.load(fi)
Traceback (most recent c
A thousand apologies, the "possibly just for Pradeep, goto", was a meant
as a light joke not to be taken personally. Goto was the original issue
with Basic.
You hit the nail squarely on the head when you say "The *users* of PHP
tend to get wired in weird ways after using it". So do the user
Hey Hey, no need to dis Php, or Drupal for that matter, it's actually a
mighty fine language for what it does. And they have been making it a lot
better(namespaces, closures and, possibly just for Pradeep, goto).
Nice to see conferences happening around python.
On Sun, 04 Oct 2009 11:47:27 +
This should work,
find f(6)**(10 raised to 7)
On Mon, 14 Sep 2009 18:36:57 +0530, Shashwat Anand
wrote:
How do we calculate last 5-digits of 10**12 ignoring trailing zeros. The
code i wrote works good until 10**8 and after that take ages.
The source of problem is Project Euler :
http://p
What's on your mind?
On Sat, 12 Sep 2009 01:51:57 +0530, Noufal Ibrahim
wrote:
Hello everyone,
Are there any people here who are interested and who've worked on
the actual CPython (or any other) interpreter directly? The whole idea
of unladen swallow is appealing to me and if there are
Hi,
You could try the C preprocessor. Personally, I'd just go for python's
inbult logging framework, and worry about the performance issue later.
Regards
On Mon, Jun 8, 2009 at 1:07 AM, Vishal wrote:
> Hello,
> We would like to have debug and release versions of our scripts. However
> since
Do this instead
cur.execute('select * from Employee where id in (%s)', ids.join(', '));
On Wed, Dec 17, 2008 at 5:13 PM, Vijay Ramachandran wrote:
> Hello.
>
> I'm unable to figure out how to use mysqldb (actually, dbabi) to write an
> "in" query.
>
> For instance, suppose my table looks like th
Hi Sonny,
Not if you run kev={} in front of your code. It will keep getting
reinitialized to an empty dict.
On Fri, Aug 29, 2008 at 3:42 PM, sunny_plone <[EMAIL PROTECTED]> wrote:
>
> hi ,
> actually my main problem is the the key name or Name should store multiple
> values, but now the old va
Any number with a decimal point is treated as an object of type float and
the numbers without a decimal point of are treated as ints. You can use the
type function to find the type of an object.
>>> type(1)
>>> type(1.0)
>>> 1+1.0
2.0
Arithmetic operations over two types give the result in the
I'm sure there a lot of guys in bangpypers who could fit that bill. I don't
think you have to have all of the qualification in point one.
What I'd like to know is how successful people who post job requirements on
bangpypers have been with recruitment. Vijay?
On Sat, Jul 5, 2008 at 3:40 PM, Anan
Hi,
You can simulate annotation using decorators. I might be missing
something about annotation but you can do this.
def annotate(returns, **params):
def decorate(func):
params['returns'] = returns
func.__annotations__ = params
return func
return decorate
@
H Heshan,
Can you explain why you'd want to do this?
You can write
def f():
print f.a
f.a = 4
f()
But I can't see you would want to do something like that. Maybe if you
give a use case. Someone can come up with a solution.
Regards,
Sidharth
On Apr 3, 2008, at 2:03 PM, Heshan Suriya
30 matches
Mail list logo