473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Is time.time() < time.time() always true?

So, I was blazin' some mad chronix, as they say, and got on to thinking
about Python.

The question was, is the statement:

time.time() < time.time()

always true? Seems it should be false, since the statement itself
occurs at one time instant.. but of course we know that python doesn't
execute code that way.. So my question is, why doesn't Python work this
way?
(PS, I wasn't smoking anything, its a figure of speech :) )

Nov 21 '06 #1
8 1453
On 21 Nov 2006 15:10:25 -0800, flamesrock <fl********@gmail.comwrote:
So, I was blazin' some mad chronix, as they say, and got on to thinking
about Python.

The question was, is the statement:

time.time() < time.time()

always true? Seems it should be false, since the statement itself
occurs at one time instant.. but of course we know that python doesn't
execute code that way.. So my question is, why doesn't Python work this
way?
This would only be false if the time between the 2 calls was less than
the precision of the OS call that time.time uses.
Nov 21 '06 #2
flamesrock wrote:
always true? Seems it should be false, since the statement itself
occurs at one time instant.. but of course we know that python
doesn't execute code that way..
C++ also wouldn't. How could multiple object instantiations be
atomic?

Regards,
Björn

--
BOFH excuse #42:

spaghetti cable cause packet failure

Nov 21 '06 #3
At Tuesday 21/11/2006 20:10, flamesrock wrote:
>The question was, is the statement:

time.time() < time.time()

always true? Seems it should be false, since the statement itself
occurs at one time instant.. but of course we know that python doesn't
execute code that way.. So my question is, why doesn't Python work this
way?
The only thing Python can guarantee, is that the left expression is
evaluated before the right one (5.13 Evaluation order, Language Reference).

Then, whether the first call yields a result always less (or equal)
to the second, is out of Python scope (and control).
(They might be equal if both calls get the same quantum of time; they
might be reversed if some other process sets the time in the past).
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
Nov 22 '06 #4
Gabriel Genellina <ga******@yahoo.com.arwrites:
The only thing Python can guarantee, is that the left expression is
evaluated before the right one (5.13 Evaluation order, Language
Reference).
Thanks, that answers my question asked elsewhere.

--
\ "One thing vampire children have to be taught early on is, |
`\ don't run with a wooden stake." -- Jack Handey |
_o__) |
Ben Finney

Nov 22 '06 #5
Hi all:

From my experience with os's.
Time is updated at intervals- they may be as low as 1mS See . So for that
millisecond multiple readings of the time will always return the same
result. Therefore time.time() < time.time() will be false for most readings.

However the result could be true if you catch the exact time when the os
updates its clock. It will only be True for a single execution of the line
and you will have to be lucky to catch it at just the right time.

Of course if you hard loop over the interval its possible to see the
transition.

for x in xrange (10000):
t = time.time()
if t < time.time:
print "transition at ", t

Enjoy.
Andy

"Ben Finney" <bi****************@benfinney.id.auwrote in message
news:ma**************************************@pyth on.org...
Gabriel Genellina <ga******@yahoo.com.arwrites:
>The only thing Python can guarantee, is that the left expression is
evaluated before the right one (5.13 Evaluation order, Language
Reference).

Thanks, that answers my question asked elsewhere.

--
\ "One thing vampire children have to be taught early on is, |
`\ don't run with a wooden stake." -- Jack Handey |
_o__) |
Ben Finney

Nov 22 '06 #6
"flamesrock" <fl********@gmail.comwrote:

8<----------------------------------
.... since the statement itself
occurs at one time instant..
nothing, but nothing, can occur at one time instant....

- Hendrik

Nov 22 '06 #7
"Hendrik van Rooyen" <ma**@microcorp.co.zawrote:
>"flamesrock" <fl********@gmail.comwrote:

8<----------------------------------
>.... since the statement itself
occurs at one time instant..

nothing, but nothing, can occur at one time instant....
Well, as long as we're being pedantic, surely that should read "only one
thing can occur at any time instant..."
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 23 '06 #8
"Tim Roberts" <ti**@probo.comwrote:

"Hendrik van Rooyen" <ma**@microcorp.co.zawrote:
"flamesrock" <fl********@gmail.comwrote:

8<----------------------------------
.... since the statement itself
occurs at one time instant..
nothing, but nothing, can occur at one time instant....

Well, as long as we're being pedantic, surely that should read "only one
thing can occur at any time instant..."
No its worse than that - what I mean is that everything takes finite time...

:-) Hendrik
Nov 24 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
13
by: dpj5754 | last post by:
Is there a simple and determinist way to make the difference between the 2 sequences: <XX></XX> and <XX/> The EndElement callback does not provide this information.
2
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display...
72
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and...
16
by: kerberoz | last post by:
which is faster? If strMessage <> String.Empty Then End If or If Not strMessage Is Nothing Then
11
by: jesdynf | last post by:
I'm having trouble applying a stylesheet to content I'm generating after the fact. Here's the sample code: <html> <head> <title>CSS/DOM Problem Example</title> <style type="text/css">...
8
by: pbd22 | last post by:
hi. i have spent the past week (i am afraid) trying to get the below script for uploading files via a hidden iframe to work. i have narrowed down my problem to the possibility that IE doesnt...
10
by: arnuld | last post by:
It is quite an ugly hack but it is all I am able to come up with for now :-( and it does the requires work. I want to improve the program, I know you people have much better ideas ;-) /* C++...
2
by: Envergure | last post by:
Is there a way to get the clock time besides clock()? Here's my specific problem: I wrote a little "free camera" application in C++, using OpenGL and SDL. Its camera was controlled with...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.