Re: Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-02 Thread Dennis Lee Bieber
On Thu, 2 Mar 2023 12:45:50 +1100, Chris Angelico declaimed the following: > >As have all CPUs since; it's the only way to implement locks (push the >locking all the way down to the CPU level). > Xerox Sigma (circa 1970): Modify and Test (byte/halfword/word) Granted, that was a

Re: Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-01 Thread Jon Ribbens via Python-list
On 2023-03-02, Chris Angelico wrote: > On Thu, 2 Mar 2023 at 08:01, <2qdxy4rzwzuui...@potatochowder.com> wrote: >> On 2023-03-01 at 14:35:35 -0500, >> avi.e.gr...@gmail.com wrote: >> > What would have happened if all processors had been required to have >> > some low level instruction that effecti

Re: Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-01 Thread Chris Angelico
On Thu, 2 Mar 2023 at 13:02, Weatherby,Gerard wrote: > > So I guess we know what would have happened. > Yep. It's not what I was talking about, but it's also a very important concurrency management feature. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-01 Thread Weatherby,Gerard
So I guess we know what would have happened. Get Outlook for iOS<https://aka.ms/o0ukef> From: Python-list on behalf of Chris Angelico Sent: Wednesday, March 1, 2023 8:45:50 PM To: python-list@python.org Subject: Re: Look free ID genertion (was: Is there

Re: Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-01 Thread Chris Angelico
On Thu, 2 Mar 2023 at 08:01, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2023-03-01 at 14:35:35 -0500, > avi.e.gr...@gmail.com wrote: > > > What would have happened if all processors had been required to have > > some low level instruction that effectively did something in an atomic > > way

Re: Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-01 Thread 2QdxY4RzWzUUiLuE
On 2023-03-01 at 14:35:35 -0500, avi.e.gr...@gmail.com wrote: > What would have happened if all processors had been required to have > some low level instruction that effectively did something in an atomic > way that allowed a way for anyone using any language running on that > machine a way to do

Re: Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-01 Thread Chris Angelico
le purpose of a use in locks. That's not lock-free :) The only way that it works is because it's locked against other threads doing the same job. Lock-free ID generation means that: 1) Two threads can request IDs simultaneously and will not block each other 2) No two "request an ID&qu

RE: Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-01 Thread avi.e.gross
very directly using the atomic operation directly. -Original Message- From: Python-list On Behalf Of Dieter Maurer Sent: Wednesday, March 1, 2023 1:43 PM To: Chris Angelico Cc: python-list@python.org Subject: Look free ID genertion (was: Is there a more efficient threading lock?) Chris

Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-01 Thread Dieter Maurer
Chris Angelico wrote at 2023-3-1 12:58 +1100: > ... > The >atomicity would be more useful in that context as it would give >lock-free ID generation, which doesn't work in Python. I have seen `itertools.count` for that. This works because its `__next__` is implemented in "C&q

Re: id

2017-08-24 Thread Steve D'Aprano
On Fri, 25 Aug 2017 12:42 am, Stefan Ram wrote: > i = 0 > while True: print( f"{ i }:{ id( i )}" ); i = i + 1 > > This loop prints increasing ids while i is less than > 257, and then it starts to print alternating ids. Try running it under Jython or IronPython. Try

Re: id

2017-08-24 Thread alister via Python-list
On Thu, 24 Aug 2017 11:21:27 -0400, Ned Batchelder wrote: > On 8/24/17 10:42 AM, Stefan Ram wrote: >> i = 0 while True: print( f"{ i }:{ id( i )}" ); i = i + 1 >> >> This loop prints increasing ids while i is less than 257, and then it >> starts to print a

Re: id

2017-08-24 Thread Ned Batchelder
On 8/24/17 10:42 AM, Stefan Ram wrote: > i = 0 > while True: print( f"{ i }:{ id( i )}" ); i = i + 1 > > This loop prints increasing ids while i is less than > 257, and then it starts to print alternating ids. > > So this seems to indicate that temporary ob

how to faster to know which ast name or id we want to change?

2016-10-12 Thread meInvent bbird
how to faster to know which ast name or id we want to change? because i use ast.walk to print all nodes then i know the name + is Add if using cparser to parse linux kernel, it will be a very large -- https://mail.python.org/mailman/listinfo/python-list

Usenet Message-ID (was Re: How to waste computer memory?)

2016-03-19 Thread Random832
> I approved a post thinking it was something else. Speaking of Usenet, I've noticed some threading problems caused by messages having their Message-ID rewritten when they're sent _to_ Usenet... for example, your message is Message-ID: <56ec5afc.6020...@timgolden.me.uk> but the Usenet

Re: why does id(multiprocessing.Process.start) == id(multiprocessing.Process.start)?

2015-08-17 Thread random832
On Mon, Aug 17, 2015, at 18:25, alex.fl...@gmail.com wrote: > Sorry I completely mistype that. It was supposed to read: > > >>> id(multiprocessing.Process.is_alive) == id(multiprocessing.Process.start) > True > > >>> multiprocessing.Process.is_alive is multip

Re: why does id(multiprocessing.Process.start) == id(multiprocessing.Process.start)?

2015-08-17 Thread Ian Kelly
On Mon, Aug 17, 2015 at 4:57 PM, Chris Kaynor wrote: > The rules for the id is that they are only guaranteed unique during the > lifespan of both objects. Also, generally, you do not want to use id or is > for much of anything unless you really know what you are doing - generally, > y

Re: why does id(multiprocessing.Process.start) == id(multiprocessing.Process.start)?

2015-08-17 Thread Chris Kaynor
On Mon, Aug 17, 2015 at 3:25 PM, wrote: > > Sorry I completely mistype that. It was supposed to read: > > >>> id(multiprocessing.Process.is_alive) == > id(multiprocessing.Process.start) > True > What is going on here is that it get multiprocessing.Process.is_aliv

Re: why does id(multiprocessing.Process.start) == id(multiprocessing.Process.start)?

2015-08-17 Thread alex . flint
On Monday, August 17, 2015 at 3:24:22 PM UTC-7, alex@gmail.com wrote: > using Python 2.7.9, I get the following: > > >>> id(multiprocessing.Process.start) == id(multiprocessing.Process.start) > True > > But on the other hand: > > >

why does id(multiprocessing.Process.start) == id(multiprocessing.Process.start)?

2015-08-17 Thread alex . flint
using Python 2.7.9, I get the following: >>> id(multiprocessing.Process.start) == id(multiprocessing.Process.start) True But on the other hand: >>> multiprocessing.Process.start is multiprocessing.Process.start False I thought that these two expressions were equivalent. Can s

Re: id() and is operator

2015-02-22 Thread Marko Rauhamaa
Terry Reedy : > On 2/22/2015 4:25 PM, Marko Rauhamaa wrote: >> This is a true statement: >> >> If X is Y, then id(X) == id(Y). >> >> However, this is generally not a true statement: >> >> If X is Y, then id(X) is id(Y). > > If X and Y e

Re: id() and is operator

2015-02-22 Thread Gary Herron
On 02/22/2015 10:02 PM, Terry Reedy wrote: On 2/22/2015 4:25 PM, Marko Rauhamaa wrote: LJ : id(b[0]) 4582 [...] id(b[2]) 4582 Please correct me if I am wrong, but according to this b[2] and b[0] are the same object. Now, b[0] is b[2] False This is a true statement: If

Re: id() and is operator

2015-02-22 Thread Terry Reedy
On 2/22/2015 12:53 PM, LJ wrote: Hi everyone. Quick question here. Lets suppose if have the following numpy array: b=np.array([[0]*2]*3) and then: id(b[0]) 4582 id(b[1]) 45857512 id(b[2]) 4582 Please correct me if I am wrong, You are, as other explained > but according

Re: id() and is operator

2015-02-22 Thread Terry Reedy
On 2/22/2015 4:25 PM, Marko Rauhamaa wrote: LJ : id(b[0]) 4582 [...] id(b[2]) 4582 Please correct me if I am wrong, but according to this b[2] and b[0] are the same object. Now, b[0] is b[2] False This is a true statement: If X is Y, then id(X) == id(Y). However, this

Re: id() and is operator

2015-02-22 Thread Steven D'Aprano
LJ wrote: > Hi everyone. Quick question here. Lets suppose if have the following numpy > array: > > b=np.array([[0]*2]*3) > > and then: > >>>> id(b[0]) > 45855552 >>>> id(b[1]) > 45857512 >>>> id(b[2]) > 4582 > >

Re: id() and is operator

2015-02-22 Thread Chris Angelico
On Mon, Feb 23, 2015 at 8:25 AM, Marko Rauhamaa wrote: > This is a true statement: > >If X is Y, then id(X) == id(Y). > > However, this is generally not a true statement: > > If X is Y, then id(X) is id(Y). Irrelevant, because the identities of equal integers

Re: id() and is operator

2015-02-22 Thread Marko Rauhamaa
LJ : >>>> id(b[0]) > 45855552 [...] >>>> id(b[2]) > 4582 > > Please correct me if I am wrong, but according to this b[2] and b[0] > are the same object. Now, > >>>> b[0] is b[2] > False This is a true statement: If X is Y, th

Re: id() and is operator

2015-02-22 Thread Laura Creighton
Ooops, I missed the numpy, so I thought that it was the contents of the array that was causing the problem. My very bad. Apologies. Laura -- https://mail.python.org/mailman/listinfo/python-list

Re: id() and is operator

2015-02-22 Thread Gary Herron
On 02/22/2015 09:53 AM, LJ wrote: Hi everyone. Quick question here. Lets suppose if have the following numpy array: b=np.array([[0]*2]*3) and then: id(b[0]) 4582 id(b[1]) 45857512 id(b[2]) 4582 Please correct me if I am wrong, but according to this b[2] and b[0] are the same

Re: id() and is operator

2015-02-22 Thread Chris Angelico
On Mon, Feb 23, 2015 at 5:13 AM, Laura Creighton wrote: > In a message of Sun, 22 Feb 2015 09:53:33 -0800, LJ writes: >>Hi everyone. Quick question here. Lets suppose if have the following numpy >>array: >> >>b=np.array([[0]*2]*3) >> >>and then: &g

Re: id() and is operator

2015-02-22 Thread Laura Creighton
In a message of Sun, 22 Feb 2015 09:53:33 -0800, LJ writes: >Hi everyone. Quick question here. Lets suppose if have the following numpy >array: > >b=np.array([[0]*2]*3) > >and then: > >>>> id(b[0]) >45855552 >>>> id(b[1]) >45857512 >>>

id() and is operator

2015-02-22 Thread LJ
Hi everyone. Quick question here. Lets suppose if have the following numpy array: b=np.array([[0]*2]*3) and then: >>> id(b[0]) 45855552 >>> id(b[1]) 45857512 >>> id(b[2]) 4582 Please correct me if I am wrong, but according to this b[2] and b[0] are the same ob

Re: id == vs is

2014-10-27 Thread Roy Smith
In article , Cameron Simpson wrote: > The "is" test is more direct and less subject to iffiness because the longer > expression using id() leaves more scope/time for things to change, and of > course "id" itself can be rebound to something weird. Not to mention

Re: id == vs is

2014-10-26 Thread Ben Finney
Ben Finney writes: > Dan Stromberg writes: > > Are the following two expressions the same? […] > > It depends what you mean by “the same”. My apologies, I mis-read the question. My answers were for a different question (one you didn't ask). Please ignore that. -- \ “If you ever reach to

Re: id == vs is

2014-10-26 Thread Cameron Simpson
On 27Oct2014 00:41, MRAB wrote: On 2014-10-27 00:24, Ethan Furman wrote: On 10/26/2014 05:23 PM, Ethan Furman wrote: On 10/26/2014 05:12 PM, Dan Stromberg wrote: Are the following two expressions the same? x is y Id(x) == id(y) ? Listen to MRAB, ignore me. That is all. Well, apart of

Re: id == vs is

2014-10-26 Thread Denis McMahon
On Sun, 26 Oct 2014 17:12:29 -0700, Dan Stromberg wrote: > Are the following two expressions the same? > > x is y > > Id(x) == id(y) No, although if "Id" and "id" were the same function, they might be equivalent in some cases. -- Denis McMahon,

Re: id == vs is

2014-10-26 Thread Ben Finney
Dan Stromberg writes: > Are the following two expressions the same? > > x is y > > Id(x) == id(y) It depends what you mean by “the same”. Do they give the same result? Sometimes yes, sometimes no. It depends on what the types of the values are. Do they express the same intent?

Re: id == vs is

2014-10-26 Thread MRAB
On 2014-10-27 00:24, Ethan Furman wrote: On 10/26/2014 05:23 PM, Ethan Furman wrote: On 10/26/2014 05:12 PM, Dan Stromberg wrote: Are the following two expressions the same? x is y Id(x) == id(y) ? Listen to MRAB, ignore me. That is all. Well, apart of Joshua's qualifications, th

Re: id == vs is

2014-10-26 Thread Ethan Furman
On 10/26/2014 05:12 PM, Dan Stromberg wrote: Are the following two expressions the same? x is y Id(x) == id(y) ? Nope. If the value if `id(x)` is not interned, then the two value could be different objects that still represent the same value. -- ~Ethan~ -- https://mail.python.org

Re: id == vs is

2014-10-26 Thread Ethan Furman
On 10/26/2014 05:23 PM, Ethan Furman wrote: On 10/26/2014 05:12 PM, Dan Stromberg wrote: Are the following two expressions the same? x is y Id(x) == id(y) ? Listen to MRAB, ignore me. That is all. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: id == vs is

2014-10-26 Thread Joshua Landau
On 27 October 2014 00:12, Dan Stromberg wrote: > Are the following two expressions the same? > > x is y > > Id(x) == id(y) Much of the time, but not all the time. The obvious exception is if "id" is redefined, but that one's kind of boring. The real thing to watch

Re: id == vs is

2014-10-26 Thread MRAB
On 2014-10-27 00:12, Dan Stromberg wrote: Are the following two expressions the same? x is y Id(x) == id(y) ? Yes. I ported some Java code to Python, and it was using Java's idea of equality (via ==) in some places. Right now, I have a suite of unit tests working using the s

id == vs is

2014-10-26 Thread Dan Stromberg
Are the following two expressions the same? x is y Id(x) == id(y) ? I ported some Java code to Python, and it was using Java's idea of equality (via ==) in some places. Right now, I have a suite of unit tests working using the second expression above, but I'm thinking about switch

Re: Thread-ID - how much could be?

2014-09-16 Thread Thomas Rachel
Am 11.09.2014 23:32 schrieb Ervin Hegedüs: There is no upper limit to the thread name other than that you will eventually run out of memory ;) thanks - I hope that the memory will not run out by these threads... :) Anyway, that means, on my system: import sys print sys.maxint 9223372036854

Re: Thread-ID - how much could be?

2014-09-13 Thread Ervin Hegedüs
On Sat, Sep 13, 2014 at 12:09:28PM +0200, Martin Skjöldebrand wrote: > Unfortunately we will never know 😢 hehe :), joke of the day :) thanks, a. -- I � UTF-8 -- https://mail.python.org/mailman/listinfo/python-list

Re: Thread-ID - how much could be?

2014-09-13 Thread Martin Skjöldebrand
Unfortunately we will never know 😢 Sent from Blue Mail On 12 Sep 2014 07:43, at 07:43, Chris Angelico wrote: >On Fri, Sep 12, 2014 at 1:41 PM, Cameron Simpson wrote: >> On 12Sep2014 11:29, Steven D'Aprano > >> wrote: >>> >>> [...]maxint. I know that some Linux >>> systems can have an uptime o

Re: Thread-ID - how much could be?

2014-09-13 Thread Peter Otten
dieter wrote: > Ervin Hegedüs writes: >> ... > What is used as thread id is platform dependent. Likely, it depends > on the thread support of the underlying C libary (i.e. the > operating system thread support). > > Under Linux, thread ids seem to be addresses - i.

Re: Thread-ID - how much could be?

2014-09-12 Thread dieter
Ervin Hegedüs writes: > ... What is used as thread id is platform dependent. Likely, it depends on the thread support of the underlying C libary (i.e. the operating system thread support). Under Linux, thread ids seem to be addresses - i.e. very large integers. -- https://mail.python.

Re: Thread-ID - how much could be?

2014-09-11 Thread Ervin Hegedüs
Hi Steven, On Fri, Sep 12, 2014 at 11:29:56AM +1000, Steven D'Aprano wrote: > import sys > print sys.maxint > > 9223372036854775807 > > > > the couter could be 9223372036854775807? > > > > And after? :) > > Suppose you somehow managed to create 9223372036854775807 threads. If your > c

Re: Thread-ID - how much could be?

2014-09-11 Thread Chris Angelico
On Fri, Sep 12, 2014 at 1:41 PM, Cameron Simpson wrote: > On 12Sep2014 11:29, Steven D'Aprano > wrote: >> >> [...]maxint. I know that some Linux >> systems can have an uptime over a year, perhaps even two years, but I >> think >> that nearly 300 years is asking a bit much. > > > 2 years is nothin

Re: Thread-ID - how much could be?

2014-09-11 Thread Cameron Simpson
On 12Sep2014 11:29, Steven D'Aprano wrote: [...]maxint. I know that some Linux systems can have an uptime over a year, perhaps even two years, but I think that nearly 300 years is asking a bit much. 2 years is nothing. Unless they have a particularly buggy kernel, most UNIX systems, Linux in

Re: Thread-ID - how much could be?

2014-09-11 Thread Chris Angelico
On Fri, Sep 12, 2014 at 11:29 AM, Steven D'Aprano wrote: > I know that some Linux > systems can have an uptime over a year, perhaps even two years, but I think > that nearly 300 years is asking a bit much. Your hardware probably won't > keep working that long. I've had over two years of uptime. C

Re: Thread-ID - how much could be?

2014-09-11 Thread Skip Montanaro
about other ways his program could fail besides overflowing some nonexistent max thread id. :-) Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Thread-ID - how much could be?

2014-09-11 Thread Steven D'Aprano
Ervin Hegedüs wrote: [...] >> > My question is: how much thread ID could be totally? Is there any >> > maximum number? And if the thread reached that, what will be >> > done? Overlflowed? Couting from 0 again? [...] >> There is no upper limit to the thr

Re: Thread-ID - how much could be?

2014-09-11 Thread Peter Otten
Ervin Hegedüs wrote: > Hi Peter, > > thanks for the reply, > > On Thu, Sep 11, 2014 at 09:48:18PM +0200, Peter Otten wrote: >> Ervin Hegedüs wrote: >> >> > Exception in thread Thread-82: >> > ... >> > My question is: how much thread ID coul

Re: Thread-ID - how much could be?

2014-09-11 Thread Ervin Hegedüs
Hi Peter, thanks for the reply, On Thu, Sep 11, 2014 at 09:48:18PM +0200, Peter Otten wrote: > Ervin Hegedüs wrote: > > > Exception in thread Thread-82: > > ... > > My question is: how much thread ID could be totally? Is there any > > maximum number? And if the thr

Re: Thread-ID - how much could be?

2014-09-11 Thread Peter Otten
main function allows 2 thread to run simultaniously, and if > the thread finished, then it joined with th.join(), where the > "th" is the thread item, derived from threading.Thread class. > > My question is: how much thread ID could be totally? Is there any > maximum number? An

Thread-ID - how much could be?

2014-09-11 Thread Ervin Hegedüs
the thread finished, then it joined with th.join(), where the "th" is the thread item, derived from threading.Thread class. My question is: how much thread ID could be totally? Is there any maximum number? And if the thread reached that, what will be done? Overlflowed? Couting from 0 again?

Re: how can I retrieve a particular tweet, having its tweet id?

2013-09-23 Thread Terry Reedy
On 9/23/2013 2:10 PM, Andres Soto wrote: how can I retrieve a particular tweet, having its tweet id, and the username, the date and the language? What, if anything, have you done to try to solve this yourself? Like searching the web? ('Python twitter' for instance) -- Terry

how can I retrieve a particular tweet, having its tweet id?

2013-09-23 Thread Andres Soto
 how can I retrieve a particular tweet, having its tweet id, and the username, the date and the language? Regards Andrés Soto -- https://mail.python.org/mailman/listinfo/python-list

Re: is operator versus id() function

2013-04-06 Thread Nobody
On Fri, 05 Apr 2013 06:49:14 -0700, Candide Dandide wrote: > So, could someone please explain what exactly the is operator returns ? > The official doc says : > > The ‘is‘ operator compares the identity of two objects; the id() > function returns an integer representing its iden

Re: is operator versus id() function

2013-04-05 Thread Tim Delaney
unexpected behavior. > Thanks for the demonstrative snippet of code and the instructive answer. > If you read the docs for id() < http://docs.python.org/3.3/library/functions.html#id>, you will see that it says: Return the "identity" of an object. This is an integer which i

Re: is operator versus id() function

2013-04-05 Thread candide
Le vendredi 5 avril 2013 16:53:55 UTC+2, Arnaud Delobelle a écrit : > > You've fallen victim to the fact that CPython is very quick to collect > > garbage. OK, I get it but it's a fairly unexpected behavior. Thanks for the demonstrative snippet of code and the instructive answer. -- http

Re: is operator versus id() function

2013-04-05 Thread Arnaud Delobelle
On 5 April 2013 14:49, Candide Dandide wrote: > Until now, I was quite sure that the is operator acts the same as the id > builtin function, or, to be more formal, that o1 is o2 to be exactly > equivalent to id(o1) == id(o2). This equivalence is reported in many books, >

is operator versus id() function

2013-04-05 Thread Candide Dandide
Until now, I was quite sure that the is operator acts the same as the id builtin function, or, to be more formal, that o1 is o2 to be exactly equivalent to id(o1) == id(o2). This equivalence is reported in many books, for instance Martelli's Python in a Nutshell. But with the following

Re: addressof object with id()

2013-03-24 Thread Steven D'Aprano
On Sun, 24 Mar 2013 06:54:08 +, Nobody wrote: > More generally, an implementation *may* intern any immutable value, > although it's not guaranteed to do so for anything except (IIRC) False, > True and None. I believe the same also applies to NotImplemented and Ellipsis, although I'm too lazy

Re: addressof object with id()

2013-03-24 Thread Peter Otten
Steven D'Aprano wrote: > On Sat, 23 Mar 2013 21:00:07 -0400, Roy Smith wrote: > >> In article , >> Fabian von Romberg wrote: >> >>> Hi, >>> >>> I have a single questions regarding id() built-in function. >>> >>> exa

Re: addressof object with id()

2013-03-23 Thread Nobody
On Sat, 23 Mar 2013 19:37:35 -0500, Fabian von Romberg wrote: > I have a single questions regarding id() built-in function. > > example 1: > > var1 = "some string" > var2 = "some string" > > if use the id() function on both, it returns exactly t

Re: addressof object with id()

2013-03-23 Thread rusi
On Mar 24, 8:33 am, Chris Angelico wrote: > On Sun, Mar 24, 2013 at 1:19 PM, Roy Smith wrote: > > In article <514e5f1f$0$30001$c3e8da3$54964...@news.astraweb.com>, > >  Steven D'Aprano wrote: > > >> Those who don't do serious floating point work hate NANs > > > This kind of thing doesn't just co

Re: addressof object with id()

2013-03-23 Thread Chris Angelico
On Sun, Mar 24, 2013 at 1:19 PM, Roy Smith wrote: > In article <514e5f1f$0$30001$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Those who don't do serious floating point work hate NANs > > This kind of thing doesn't just come up in floating point work. SQL > folks have much

Re: addressof object with id()

2013-03-23 Thread Roy Smith
In article <514e5f1f$0$30001$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Those who don't do serious floating point work hate NANs This kind of thing doesn't just come up in floating point work. SQL folks have much the same issue with NULL. -- http://mail.python.org/mailman/

Re: addressof object with id()

2013-03-23 Thread Roy Smith
In article <514e5e71$0$30001$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > As far as I know, there is no Python implementation that automatically > interns strings which are not valid identifiers. "some string" is not a > valid identifier, due to the space. I stand corrected.

Re: addressof object with id()

2013-03-23 Thread Steven D'Aprano
On Sun, 24 Mar 2013 11:56:50 +1100, Chris Angelico wrote: > On Sun, Mar 24, 2013 at 11:49 AM, Dave Angel wrote: >> You can assume that if the id's are equal, the objects are equal. But >> you can't assume the inverse or the converse. > > To be more specific: If the ids are equal, the objects ar

Re: addressof object with id()

2013-03-23 Thread Steven D'Aprano
On Sat, 23 Mar 2013 21:00:07 -0400, Roy Smith wrote: > In article , > Fabian von Romberg wrote: > >> Hi, >> >> I have a single questions regarding id() built-in function. >> >> example 1: >> >> var1 = "some string" >> var2

Re: addressof object with id()

2013-03-23 Thread Steven D'Aprano
On Sat, 23 Mar 2013 19:37:35 -0500, Fabian von Romberg wrote: > Hi, > > I have a single questions regarding id() built-in function. > > example 1: > > var1 = "some string" > var2 = "some string" > > if use the id() function on both, it returns

Re: addressof object with id()

2013-03-23 Thread Chris Angelico
On Sun, Mar 24, 2013 at 12:00 PM, Roy Smith wrote: > I had thought interning only affected > string literals, but apparently it works for all strings! This works > too: > >>>> a = "b" + "ar" >>>> b = "ba" + "r" >>

Re: addressof object with id()

2013-03-23 Thread Roy Smith
In article , Chris Angelico wrote: > On Sun, Mar 24, 2013 at 11:49 AM, Dave Angel wrote: > > You can assume that if the id's are equal, the objects are equal. But you > > can't assume the inverse or the converse. > > To be more specific: If the ids are equal, the objects are identical. > Does

Re: addressof object with id()

2013-03-23 Thread Roy Smith
In article , Fabian von Romberg wrote: > Hi, > > I have a single questions regarding id() built-in function. > > example 1: > > var1 = "some string" > var2 = "some string" > > if use the id() function on both, it returns exactly

Re: addressof object with id()

2013-03-23 Thread Chris Angelico
On Sun, Mar 24, 2013 at 11:49 AM, Dave Angel wrote: > You can assume that if the id's are equal, the objects are equal. But you > can't assume the inverse or the converse. To be more specific: If the ids are equal, the objects are identical. Doesn't mean they'll compare equal - for instance, flo

Re: addressof object with id()

2013-03-23 Thread Dave Angel
On 03/23/2013 08:37 PM, Fabian von Romberg wrote: Hi, I have a single questions regarding id() built-in function. example 1: var1 = "some string" var2 = "some string" if use the id() function on both, it returns exactly the same address. example 2: data = "some

addressof object with id()

2013-03-23 Thread Fabian von Romberg
Hi, I have a single questions regarding id() built-in function. example 1: var1 = "some string" var2 = "some string" if use the id() function on both, it returns exactly the same address. example 2: data = "some string" var1 = data var2 = data if use the id()

Re: how to get the coordonnée of a line from his Id in canvas python??

2013-03-13 Thread Mark Lawrence
On 13/03/2013 15:06, olsr.ka...@gmail.com wrote: how to get the coordonnée of a line from his Id in canvas python?? Write some code after you've referred to the response you got when you posted the same question on 9th March. Please don't post to the mailing list and the gman

how to get the coordonnée of a line from his Id in canvas python??

2013-03-13 Thread olsr . kamal
how to get the coordonnée of a line from his Id in canvas python?? -- http://mail.python.org/mailman/listinfo/python-list

how to get the coordonnée of a line from his Id in canvas python??

2013-03-13 Thread olsr . kamal
how to get the coordonnée of a line from his Id in canvas python?? -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get id of a line from his coordonée in tkinter python?

2013-03-09 Thread Rick Johnson
On Saturday, March 9, 2013 4:46:40 PM UTC-6, olsr@gmail.com wrote: > how to get id of a line from his coordonée in tkinter python? Each time you create a "canvas item", be it a rectangle, line, circle, or whatever..., the id of that object is returned as an integer. All you h

how to get id of a line from his coordonée in tkinter python?

2013-03-09 Thread olsr . kamal
how to get id of a line from his coordonée in tkinter python? -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate unique ID for URL

2012-11-14 Thread Johannes Bauer
On 14.11.2012 13:33, Dave Angel wrote: > Te birthday paradox could have been important had the OP stated his goal > differently. What he said was: > > """Ideally I would want to avoid collisions altogether. But if that means > significant extra CPU time then 1 collision in 10 million hashes wou

Re: Generate unique ID for URL

2012-11-14 Thread Dave Angel
On 11/14/2012 06:29 AM, Johannes Bauer wrote: > > > When doing these calculations, it's important to keep the birthday > paradox in mind (this is kind of counter-intuitive): The chance of a > collission raises tremendously when we're looking for *any* arbitrary > two hashes colliding within a cert

Re: Generate unique ID for URL

2012-11-14 Thread Johannes Bauer
On 14.11.2012 02:39, Roy Smith wrote: > The next step is to reduce the number of bits you are encoding. You > said in another post that "1 collision in 10 million hashes would be > tolerable". So you need: > math.log(10*1000*1000, 2) > 23.25349666421154 > > 24 bits worth of key. Nope

Re: Generate unique ID for URL

2012-11-14 Thread Richard
thanks for perspective! -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate unique ID for URL

2012-11-14 Thread Johannes Bauer
On 14.11.2012 01:41, Richard Baron Penman wrote: > I found the MD5 and SHA hashes slow to calculate. Slow? For URLs? Are you kidding? How many URLs per second do you want to calculate? > The builtin hash is fast but I was concerned about collisions. What > rate of collisions could I expect? MD5

Re: Generate unique ID for URL

2012-11-13 Thread Richard
yeah good point - I have gone with md5 for now. On Wednesday, November 14, 2012 3:06:18 PM UTC+11, Chris Angelico wrote: > On Wed, Nov 14, 2012 at 2:25 PM, Richard wrote: > > > So the use case - I'm storing webpages on disk and want a quick retrieval > > system based on URL. > > > I can't sto

Re: Generate unique ID for URL

2012-11-13 Thread Chris Angelico
On Wed, Nov 14, 2012 at 2:25 PM, Richard wrote: > So the use case - I'm storing webpages on disk and want a quick retrieval > system based on URL. > I can't store the files in a single directory because of OS limitations so > have been using a sub folder structure. > For example to store data at

Re: Generate unique ID for URL

2012-11-13 Thread Richard
thanks for pointer to Varnish. I found MongoDB had a lot of size overhead so that it ended up using 4x the data stored. -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate unique ID for URL

2012-11-13 Thread Roy Smith
In article <1ce88f36-bfc7-4a55-89f8-70d1645d2...@googlegroups.com>, Richard wrote: > So the use case - I'm storing webpages on disk and want a quick retrieval > system based on URL. > I can't store the files in a single directory because of OS limitations so > have been using a sub folder str

Re: Generate unique ID for URL

2012-11-13 Thread Richard
> The next step is to reduce the number of bits you are encoding. You > > said in another post that "1 collision in 10 million hashes would be > > tolerable". So you need: > > > > >>> math.log(10*1000*1000, 2) > > 23.25349666421154 I think a difficulty would be finding a hash algorithm

Re: Generate unique ID for URL

2012-11-13 Thread Richard
So the use case - I'm storing webpages on disk and want a quick retrieval system based on URL. I can't store the files in a single directory because of OS limitations so have been using a sub folder structure. For example to store data at URL "abc": a/b/c/index.html This data is also viewed loca

Re: Generate unique ID for URL

2012-11-13 Thread Richard
I am dealing with URL's rather than integers -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate unique ID for URL

2012-11-13 Thread Roy Smith
In article <0692e6a2-343c-4eb0-be57-fe5c815ef...@googlegroups.com>, Richard wrote: > Hello, > > I want to create a URL-safe unique ID for URL's. > Currently I use: > url_id = base64.urlsafe_b64encode(url) > > >>> base64.urlsafe_b64

Re: Generate unique ID for URL

2012-11-13 Thread Richard
I found md5 / sha 4-5 times slower than hash. And base64 a lot slower. No database or else I would just use their ID. On Wednesday, November 14, 2012 11:59:55 AM UTC+11, Christian Heimes wrote: > Am 14.11.2012 01:41, schrieb Richard Baron Penman: > > > I found the MD5 and SHA ha

Re: Generate unique ID for URL

2012-11-13 Thread Christian Heimes
Am 14.11.2012 01:50, schrieb Richard: > These URL ID's would just be used internally for quick lookups, not exposed > publicly in a web application. > > Ideally I would want to avoid collisions altogether. But if that means > significant extra CPU time then 1 collision in 10 million hashes would

  1   2   3   4   5   >